Class: Hash
Instance Method Summary collapse
Instance Method Details
#from_structure(data) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/structure_mapper.rb', line 33 def from_structure data key_type, value_type=first if key_type && value_type && data Hash[data.map{|k,v| [key_type.from_structure(k), value_type.from_structure(v)]}] else data end end |
#to_structure ⇒ Object
42 43 44 45 46 |
# File 'lib/structure_mapper.rb', line 42 def to_structure Hash[self.map do |k,v| [k.to_structure, v.to_structure] end] end |