Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/extensions/hash.rb
Instance Method Summary collapse
Instance Method Details
#to_struct(struct_name) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/extensions/hash.rb', line 2 def to_struct(struct_name) if Struct.const_defined?(struct_name) struct = Struct.const_get(struct_name) else struct = Struct.new(struct_name,*keys) end struct.new(*values) end |