Class: ObjectDeepDiff::ObjectHash

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

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ObjectHash

Returns a new instance of ObjectHash.



26
27
28
29
30
31
32
# File 'lib/object_deep_diff/object_hash.rb', line 26

def initialize(object)
  @object = object

  @hash = {}

  @object_value = ObjectValue.new(@object)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



39
40
41
42
43
44
# File 'lib/object_deep_diff/object_hash.rb', line 39

def method_missing(m, *args, &block)
  prop_value = @object_value.call(m, &block)
  if (prop_value)
    @hash[m] = prop_value
  end
end

Instance Method Details

#call(&block) ⇒ Object



34
35
36
37
# File 'lib/object_deep_diff/object_hash.rb', line 34

def call(&block)
  self.instance_exec(&block)
  @hash
end