Class: Hashcraft::Mutators
- Inherits:
-
Generic::Registry
- Object
- Generic::Registry
- Hashcraft::Mutators
- Defined in:
- lib/hashcraft/mutators.rb
Overview
Singleton that knows how to register and retrieve mutator instances. Entries can either be instances that respond to value! or procs that accept three arguments.
Instance Method Summary collapse
-
#initialize ⇒ Mutators
constructor
A new instance of Mutators.
- #value!(name, data, key, value) ⇒ Object
Methods inherited from Generic::Registry
#register, #register_all, #resolve
Constructor Details
#initialize ⇒ Mutators
Returns a new instance of Mutators.
33 34 35 36 |
# File 'lib/hashcraft/mutators.rb', line 33 def initialize # append on the default case super(FUNCTIONS.merge('': FUNCTIONS[:property])) end |
Instance Method Details
#value!(name, data, key, value) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/hashcraft/mutators.rb', line 38 def value!(name, data, key, value) object = resolve(name) method = object.is_a?(Proc) ? :call : :value! object.send(method, data, key, value) end |