Module: Hashable

Included in:
Array, Hash
Defined in:
lib/hashable/version.rb,
lib/hashable/hashable.rb

Constant Summary collapse

VERSION =
'0.1.2'

Instance Method Summary collapse

Instance Method Details

#to_deep_hashObject Also known as: to_dh

Return recursively hash representation of the object

Returns:

  • hash



5
6
7
8
9
10
11
# File 'lib/hashable/hashable.rb', line 5

def to_deep_hash
  hash = {}
  instance_variables.each do |key|
    hash[key[1..-1].to_sym] = deeply_to_hash(instance_variable_get(key))
  end
  hash
end