Class: Hana::Patch

Inherits:
Object
  • Object
show all
Defined in:
lib/hana.rb

Defined Under Namespace

Classes: Exception, FailedTestException, IndexError, InvalidPath, MissingTargetException, ObjectOperationOnArrayException, OutOfBoundsException

Constant Summary collapse

VALID =

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(is) ⇒ Patch

Returns a new instance of Patch.



85
86
87
# File 'lib/hana.rb', line 85

def initialize is
  @is = is
end

Instance Method Details

#apply(doc) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/hana.rb', line 91

def apply doc
  @is.inject(doc) { |d, ins|
    send VALID.fetch(ins[OP].strip) { |k|
      raise Exception, "bad method `#{k}`"
    }, ins, d
  }
end