Module: Destruct::Object

Defined in:
lib/destruct/object.rb

Instance Method Summary collapse

Instance Method Details

#destruct(*paths, &block) ⇒ Object



3
4
5
# File 'lib/destruct/object.rb', line 3

def destruct(*paths, &block)
  Destruct.new(self, *paths, &block).to_h
end

#dig(method, *paths) ⇒ Object



7
8
9
10
# File 'lib/destruct/object.rb', line 7

def dig(method, *paths)
  object = send(method) if respond_to?(method)
  paths.any? ? object&.dig(*paths) : object
end