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.



71
72
73
# File 'lib/hana.rb', line 71

def initialize is
  @is = is
end

Instance Method Details

#apply(doc) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/hana.rb', line 77

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