lib/eco/api/session/config.rb in eco-helpers-3.0.14 vs lib/eco/api/session/config.rb in eco-helpers-3.0.15

- old
+ new

@@ -95,27 +95,45 @@ # @return [Boolean] `true` if there is any api configuration defined, `false` otherwise def apis? apis.apis? end + ApiDefChain = Struct.new(:root, :name, :params) do + def add_space(space, **kargs, &block) + kargs = (params || {}).merge(kargs).merge(space: space) + root.add_api(name, **kargs, &block) + end + end + # @param (see Eco::API::Session::Config::Apis#add) # @return [Eco::API::Session::Config] this configuration def add_api(name, **kargs) apis.add(name, **kargs) - self + + if block_given? + params = kargs.merge({space: :sub_other}) + yield(ApiDefChain.new(self, name, params)) + end + + ApiDefChain.new(self, name, {space: :other}) end # Set the active api by `name` # @see Eco::API::Session::Config::Apis#active_api= # @return [Eco::API::Session::Config] this configuration - def active_api(name) - apis.active_name = name + def active_api(name, space: nil) + apis.set_active_name(name, space: space) self end # @see Eco::API::Session::Config::Apis#active_root_name def active_enviro apis.active_root_name + end + + # @see Eco::API::Session::Config::Apis#active_space + def active_enviro_space + apis.active_space end # @see Eco::API::Session::Config::Apis#api # @return [Eco::API::Session::Config::Api] the currently active api def api(logger = ::Logger.new(IO::NULL), version: nil)