Module: Usable::ConfigMulti
- Included in:
- Config
- Defined in:
- lib/usable/config_multi.rb
Instance Method Summary collapse
-
#+(other) ⇒ Object
It’s important to define all block specs we need to lazy load.
Instance Method Details
#+(other) ⇒ Object
It’s important to define all block specs we need to lazy load
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/usable/config_multi.rb', line 4 def +(other) config = clone specs = other.spec.to_h specs.each { |key, val| config[key] = val } methods = other.spec.singleton_methods methods.map! { |name| name.to_s.tr('=', '').to_sym } methods.uniq! methods -= specs.keys methods.each do |name| config.spec.define_singleton_method(name) do other.spec.public_method(name).call end config.instance_variable_get(:@lazy_loads) << name end config end |