Class: Hash

Inherits:
Object show all
Defined in:
lib/h8/value.rb

Instance Method Summary collapse

Instance Method Details

#to_ruby(depth = 0) ⇒ Object

Hash copies in depth converting its data. Primary usage is when it was used bu javascript and could contain gated objects.

Important! that converted keys are turned to string even of were pure ruby symbols. This is done to remove ambiguity: work the same with ruby hashes, javasctipt objects, OpenStruct and Hashie::Mash instances



203
204
205
206
207
208
# File 'lib/h8/value.rb', line 203

def to_ruby depth=0
  res = {}
  depth += 1
  each { |k,v| res[k.to_ruby(depth).to_s] = v.to_ruby depth }
  res
end