Class: ROM::Registry Private
- Inherits:
-
Object
- Object
- ROM::Registry
- Extended by:
- Initializer
- Includes:
- Enumerable
- Defined in:
- lib/rom/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.
Direct Known Subclasses
AssociationSet, CommandRegistry, MapperRegistry, PluginRegistryBase, RelationRegistry
Instance Attribute Summary collapse
-
#cache ⇒ Cache
readonly
Local cache instance.
-
#elements ⇒ Hash
readonly
Internal hash for storing registry objects.
Class Method Summary collapse
- .element_not_found_error ⇒ Object private
- .new(*args) ⇒ Object private
Instance Method Summary collapse
- #each ⇒ Object private
- #fetch(key) ⇒ Object (also: #[]) private
- #key?(name) ⇒ Boolean private
- #map(&block) ⇒ Object private
- #respond_to_missing?(name, include_private = false) ⇒ Boolean private
Methods included from Initializer
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.
79 80 81 |
# File 'lib/rom/registry.rb', line 79 def method_missing(name, *) elements.fetch(name) { super } end |
Instance Attribute Details
#cache ⇒ Cache (readonly)
Returns local cache instance.
21 |
# File 'lib/rom/registry.rb', line 21 option :cache, default: -> { Cache.new } |
#elements ⇒ Hash (readonly)
Returns Internal hash for storing registry objects.
17 |
# File 'lib/rom/registry.rb', line 17 param :elements |
Class Method Details
.element_not_found_error ⇒ 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.
36 37 38 |
# File 'lib/rom/registry.rb', line 36 def self.element_not_found_error ElementNotFoundError end |
.new(*args) ⇒ 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.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rom/registry.rb', line 24 def self.new(*args) case args.size when 0 super({}, {}) when 1 super(*args, {}) else super(*args) end end |
Instance Method Details
#each ⇒ 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.
49 50 51 52 |
# File 'lib/rom/registry.rb', line 49 def each return to_enum unless block_given? 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.
60 61 62 63 64 65 66 67 68 |
# File 'lib/rom/registry.rb', line 60 def fetch(key) raise ArgumentError.new('key cannot be nil') if key.nil? elements.fetch(key.to_sym) do return yield if block_given? raise self.class.element_not_found_error.new(key, self) 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.
55 56 57 |
# File 'lib/rom/registry.rb', line 55 def key?(name) !name.nil? && elements.key?(name.to_sym) end |
#map(&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.
41 42 43 44 45 46 |
# File 'lib/rom/registry.rb', line 41 def map(&block) new_elements = elements.each_with_object({}) do |(name, element), h| h[name] = yield(element) end self.class.new(new_elements, ) 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.
72 73 74 |
# File 'lib/rom/registry.rb', line 72 def respond_to_missing?(name, include_private = false) elements.key?(name) || super end |