Class: ObjectDeepDiff::ObjectHash
- Inherits:
-
Object
- Object
- ObjectDeepDiff::ObjectHash
- Defined in:
- lib/object_deep_diff/object_hash.rb
Instance Method Summary collapse
- #call(&block) ⇒ Object
-
#initialize(object) ⇒ ObjectHash
constructor
A new instance of ObjectHash.
- #method_missing(m, *args, &block) ⇒ Object
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 |