Class: JSONPatcher::ObjectPatcher
- Inherits:
-
Object
- Object
- JSONPatcher::ObjectPatcher
- Defined in:
- lib/jsonpatcher/object_patcher.rb
Instance Method Summary collapse
- #call(hash) ⇒ Object
-
#initialize(callables) ⇒ ObjectPatcher
constructor
A new instance of ObjectPatcher.
Constructor Details
#initialize(callables) ⇒ ObjectPatcher
Returns a new instance of ObjectPatcher.
3 4 5 |
# File 'lib/jsonpatcher/object_patcher.rb', line 3 def initialize(callables) @patcher = callables end |
Instance Method Details
#call(hash) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jsonpatcher/object_patcher.rb', line 7 def call(hash) patched = {} hash.each do |k, v| patcher = @patcher[k.to_sym] if patcher patched[k] = patcher.call(v) else patched[k] = v end end patched end |