Module: Dry::Container::Nested
- Extended by:
- ClassInterface
- Defined in:
- lib/dry/container/nested.rb,
lib/dry/container/nested/version.rb
Overview
Defined Under Namespace
Modules: ClassInterface Classes: NoNameError
Constant Summary collapse
- Undefined =
Object.new do class << self def inspect 'Undefined' end alias_method :to_str, :inspect alias_method :to_s, :inspect end end.freeze
- VERSION =
'0.1.0'
Class Method Summary collapse
Instance Method Summary collapse
-
#each(&block) ⇒ Enumerator
Calls block once for each key/value pair in the container, passing the key and the registered item parameters.
-
#each_key(&block) ⇒ Dry::Container::Mixin
Calls block once for each key in container, passing the key as a parameter.
-
#keys ⇒ Array<String>
An array of registered names for the container.
Methods included from ClassInterface
apply_namespace!, key_methods, key_parameter, method_definition, redefine_method
Class Method Details
.extended(other) ⇒ Object
111 112 113 114 |
# File 'lib/dry/container/nested.rb', line 111 def self.extended(other) super raise NoNameError, other unless other.name end |
Instance Method Details
#each(&block) ⇒ Enumerator
Calls block once for each key/value pair in the container, passing the key and the registered item parameters.
If no block is given, an enumerator is returned instead.
201 202 203 204 205 206 207 208 |
# File 'lib/dry/container/nested.rb', line 201 def each(&block) container.config .resolver .each(_container) .each_with_object([]) do |(key, value), result| result << [deprefixed(key), value] if matcher.match?(key) end.each(&block) end |
#each_key(&block) ⇒ Dry::Container::Mixin
Calls block once for each key in container, passing the key as a parameter.
If no block is given, an enumerator is returned instead.
190 191 192 193 |
# File 'lib/dry/container/nested.rb', line 190 def each_key(&block) keys.each_key(&block) self end |
#keys ⇒ Array<String>
An array of registered names for the container
178 179 180 181 182 |
# File 'lib/dry/container/nested.rb', line 178 def keys container.keys.each_with_object([]) do |key, keys| keys << deprefixed(key) if matcher.match?(key) end end |