Class: Hana::Patch

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

Defined Under Namespace

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

Constant Summary collapse

VALID =

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(is) ⇒ Patch

Returns a new instance of Patch.



69
70
71
# File 'lib/hana.rb', line 69

def initialize is
  @is = is
end

Instance Method Details

#apply(doc) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/hana.rb', line 75

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