Module: ROM::Configurable::ConfigMethods Private
- Includes:
- Enumerable
- Defined in:
- lib/rom/support/configurable.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #_constructors ⇒ Object private
- #each(&block) ⇒ Object private
- #empty? ⇒ Boolean private
- #fetch ⇒ Object private
- #freeze ⇒ Object private
- #inherit(other) ⇒ Object private
- #inherit!(other) ⇒ Object private
- #join(other, direction = :left) ⇒ Object private
- #join!(other, direction = :left) ⇒ Object private
- #key?(key) ⇒ Boolean private
- #keys ⇒ Object private
- #merge(other) ⇒ Object private
- #to_h ⇒ Object (also: #to_hash) private
Instance Method Details
#_constructors ⇒ 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.
123 124 125 |
# File 'lib/rom/support/configurable.rb', line 123 def _constructors @_constructors ||= _settings.map { |setting| [setting.name, setting.constructor] }.to_h end |
#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.
47 48 49 |
# File 'lib/rom/support/configurable.rb', line 47 def each(&block) values.each(&block) end |
#empty? ⇒ 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.
91 92 93 |
# File 'lib/rom/support/configurable.rb', line 91 def empty? values.compact.empty? end |
#fetch ⇒ 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.
106 107 108 |
# File 'lib/rom/support/configurable.rb', line 106 def fetch(...) values.fetch(...) end |
#freeze ⇒ 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.
117 118 119 120 |
# File 'lib/rom/support/configurable.rb', line 117 def freeze _constructors super end |
#inherit(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.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rom/support/configurable.rb', line 57 def inherit(other) hash = values.merge(other.to_h.slice(*keys)) { |key, left, right| if _constructors[key].is_a?(Constructors::Inherit) _constructors[key].(left, right) else left.nil? ? right : left end } merge(hash) end |
#inherit!(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.
52 53 54 |
# File 'lib/rom/support/configurable.rb', line 52 def inherit!(other) update(inherit(other)) end |
#join(other, direction = :left) ⇒ 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.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rom/support/configurable.rb', line 74 def join(other, direction = :left) hash = values.merge(other.to_h.slice(*keys)) { |key, left, right| if _constructors[key].is_a?(Constructors::Join) _constructors[key].(left, right, direction) else direction == :left ? left : right end } merge(hash) end |
#join!(other, direction = :left) ⇒ 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.
69 70 71 |
# File 'lib/rom/support/configurable.rb', line 69 def join!(other, direction = :left) update(join(other, direction)) end |
#key?(key) ⇒ 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.
96 97 98 |
# File 'lib/rom/support/configurable.rb', line 96 def key?(key) _settings.key?(key) end |
#keys ⇒ 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.
101 102 103 |
# File 'lib/rom/support/configurable.rb', line 101 def keys _settings.keys 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.
86 87 88 |
# File 'lib/rom/support/configurable.rb', line 86 def merge(other) dup.update(values.merge(other)) end |
#to_h ⇒ Object Also known as: to_hash
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.
111 112 113 |
# File 'lib/rom/support/configurable.rb', line 111 def to_h values end |