Class: Hana::Patch

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

Defined Under Namespace

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

Constant Summary collapse

VALID =

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(is) ⇒ Patch

Returns a new instance of Patch.



88
89
90
# File 'lib/hana.rb', line 88

def initialize is
  @is = is
end

Instance Method Details

#apply(doc) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/hana.rb', line 94

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