Class: ROM::Registry Private
- Inherits:
-
Object
- Object
- ROM::Registry
- Extended by:
- Dry::Core::Cache, Initializer
- Includes:
- Enumerable
- Defined in:
- core/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, PluginsContainer, RelationRegistry
Instance Attribute Summary collapse
-
#cache ⇒ Cache
readonly
Local cache instance.
-
#elements ⇒ Hash
readonly
Internal hash for storing registry objects.
Class Method Summary collapse
- .[](identifier) ⇒ Object private
-
.build(elements = {}) ⇒ Object
private
Create a registry without options.
- .element_not_found_error ⇒ Object private
- .new(*args, **kwargs) ⇒ Object private
Instance Method Summary collapse
- #each ⇒ Object private
- #fetch(key) ⇒ Object (also: #[]) private
- #key?(name) ⇒ Boolean private
- #map ⇒ Object private
- #merge(other) ⇒ Object private
- #respond_to_missing?(name, include_private = false) ⇒ Boolean private
- #to_hash ⇒ Object private
- #type ⇒ Object private
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.
108 109 110 |
# File 'core/lib/rom/registry.rb', line 108 def method_missing(name, *) elements.fetch(name) { super } end |
Instance Attribute Details
#cache ⇒ Cache (readonly)
Returns local cache instance.
22 |
# File 'core/lib/rom/registry.rb', line 22 option :cache, default: -> { Cache.new } |
#elements ⇒ Hash (readonly)
Returns Internal hash for storing registry objects.
18 |
# File 'core/lib/rom/registry.rb', line 18 param :elements |
Class Method Details
.[](identifier) ⇒ 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 47 |
# File 'core/lib/rom/registry.rb', line 41 def self.[](identifier) fetch_or_store(identifier) do ::Dry::Core::ClassBuilder .new(parent: self, name: "#{name}[:#{identifier}]") .call end end |
.build(elements = {}) ⇒ 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.
Create a registry without options
36 37 38 |
# File 'core/lib/rom/registry.rb', line 36 def self.build(elements = {}) new(elements, **{}) end |
.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.
50 51 52 |
# File 'core/lib/rom/registry.rb', line 50 def self.element_not_found_error ElementNotFoundError end |
.new(*args, **kwargs) ⇒ 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.
25 26 27 28 29 30 31 |
# File 'core/lib/rom/registry.rb', line 25 def self.new(*args, **kwargs) if args.empty? && kwargs.empty? super({}, **{}) else super 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.
73 74 75 76 77 |
# File 'core/lib/rom/registry.rb', line 73 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.
85 86 87 88 89 90 91 92 93 |
# File 'core/lib/rom/registry.rb', line 85 def fetch(key) raise ArgumentError, '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.
80 81 82 |
# File 'core/lib/rom/registry.rb', line 80 def key?(name) !name.nil? && elements.key?(name.to_sym) end |
#map ⇒ 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.
65 66 67 68 69 70 |
# File 'core/lib/rom/registry.rb', line 65 def map new_elements = elements.each_with_object({}) do |(name, element), h| h[name] = yield(element) end self.class.new(new_elements, **) end |
#merge(other) ⇒ 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.
55 56 57 |
# File 'core/lib/rom/registry.rb', line 55 def merge(other) self.class.new(Hash(other), **) 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.
101 102 103 |
# File 'core/lib/rom/registry.rb', line 101 def respond_to_missing?(name, include_private = false) elements.key?(name) || super end |
#to_hash ⇒ 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.
60 61 62 |
# File 'core/lib/rom/registry.rb', line 60 def to_hash elements end |
#type ⇒ 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.
96 97 98 |
# File 'core/lib/rom/registry.rb', line 96 def type self.class.name end |