Module: JsonDiff

Includes:
Helpers
Defined in:
lib/jsondiff.rb,
lib/jsondiff/helpers.rb,
lib/jsondiff/version.rb,
lib/jsondiff/hash_diff.rb,
lib/jsondiff/array_diff.rb

Defined Under Namespace

Modules: Helpers Classes: ArrayDiff, HashDiff

Constant Summary collapse

VERSION =
'0.0.5'

Class Method Summary collapse

Methods included from Helpers

included

Class Method Details

.generate(arg1, arg2, result = [], prefix = "") ⇒ Object

Generate a patch from two ruby hash

arg1 - the first argument arg2 - the second argument

Returns an array of operations



14
15
16
17
18
19
20
21
22
23
# File 'lib/jsondiff.rb', line 14

def self.generate(arg1, arg2, result=[], prefix="")
  if Hash === arg1 && Hash === arg2
    HashDiff.generate(result, prefix, arg1, arg2)
  elsif Array === arg1 && Array === arg2
    ArrayDiff.generate(result, prefix, arg1, arg2)
  else
    result << replace_op(prefix, arg2)
  end
  result
end