class OpenStruct
def dig(name, *names)
person.dig(:address, "zip") # => 12345
person = OpenStruct.new("name" => "John Smith", "address" => address)
address = OpenStruct.new("city" => "Anytown NC", "zip" => 12345)
require "ostruct"
Examples:
See {Dig Methods}[rdoc-ref:doc/dig_methods.rdoc].
The nested objects may be instances of various classes.
that is specified by +name+ and +identifiers+.
Finds and returns the object in nested objects
ostruct.dig(name, *identifiers) -> object
:call-seq:
def dig(name, *names) begin name = name.to_sym rescue NoMethodError raise! TypeError, "#{name} is not a symbol nor a string" end @table.dig(name, *names) end