Sha256: 2889107774cef01284d9e0d15763c4745dcf19f58027a80c84be48f508dac411
Contents?: true
Size: 342 Bytes
Versions: 20
Compression:
Stored size: 342 Bytes
Contents
class Hash # A method to convert a Hash into a Struct. # # h = {:name=>"Dan","age"=>33,"rank"=>"SrA","grade"=>"E4"} # s = h.to_struct("Foo") # # TODO: Is this robust enough considerd hashes aren't ordered? # # CREDIT: Daniel Berger def to_struct(struct_name) Struct.new(struct_name,*keys).new(*values) end end
Version data entries
20 entries across 19 versions & 2 rubygems