Class: HashToStruct::StructBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_to_struct/struct_builder.rb

Class Method Summary collapse

Class Method Details

.build(hash) ⇒ Object



8
9
10
11
# File 'lib/hash_to_struct/struct_builder.rb', line 8

def build(hash)
  s = struct_class.new(nil, *hash.keys)
  s.new(*hash.values_at(*hash.keys))
end

.struct_classObject



4
5
6
# File 'lib/hash_to_struct/struct_builder.rb', line 4

def struct_class
  ::Struct
end