Class: JSONPatcher::DSL::ObjectDSL

Inherits:
JSONPatcher::DSL show all
Defined in:
lib/jsonpatcher/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from JSONPatcher::DSL

#array, #object

Class Method Details

.parse(&block) ⇒ Object



25
26
27
28
29
# File 'lib/jsonpatcher/dsl.rb', line 25

def self.parse(&block)
  parser = new
  parser.instance_eval &block
  parser.instance_variable_get(:"@patcher")
end

Instance Method Details

#property(key, callable = nil, &block) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/jsonpatcher/dsl.rb', line 31

def property(key, callable = nil, &block)
  if block_given?
    callable = DSL.parse(&block)
  end
  @patcher ||= {}
  @patcher[key] = callable
end