Class: ROM::Registry Private
- Inherits:
-
Object
- Object
- ROM::Registry
- Includes:
- Enumerable
- Defined in:
- lib/rom/support/registry.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: ElementNotFoundError
Instance Attribute Summary collapse
- #elements ⇒ Object readonly private
- #name ⇒ Object readonly private
Instance Method Summary collapse
- #each(&block) ⇒ Object private
- #fetch(key) ⇒ Object (also: #[]) private
-
#initialize(elements = {}, name = self.class.name) ⇒ Registry
constructor
private
A new instance of Registry.
- #key?(name) ⇒ Boolean private
- #respond_to_missing?(name, include_private = false) ⇒ Boolean private
Constructor Details
#initialize(elements = {}, name = self.class.name) ⇒ Registry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Registry.
15 16 17 18 |
# File 'lib/rom/support/registry.rb', line 15 def initialize(elements = {}, name = self.class.name) @elements = elements @name = name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'lib/rom/support/registry.rb', line 44 def method_missing(name, *) elements.fetch(name) { super } end |
Instance Attribute Details
#elements ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/rom/support/registry.rb', line 13 def elements @elements end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/rom/support/registry.rb', line 13 def name @name end |
Instance Method Details
#each(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 |
# File 'lib/rom/support/registry.rb', line 20 def each(&block) return to_enum unless block elements.each { |element| yield(element) } end |
#fetch(key) ⇒ Object Also known as: []
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 |
# File 'lib/rom/support/registry.rb', line 29 def fetch(key) elements.fetch(key.to_sym) do return yield if block_given? raise ElementNotFoundError.new(key, name) end end |
#key?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/rom/support/registry.rb', line 25 def key?(name) elements.key?(name.to_sym) end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/rom/support/registry.rb', line 38 def respond_to_missing?(name, include_private = false) elements.key?(name) || super end |