Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/nimo/utils/object_extension.rb
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates a new object from a hash.
Class Method Details
.from_hash(hash) ⇒ Object
Creates a new object from a hash. The hash keys will became attribute names, and the respective values will be the attribute’s value.
Example:
obj = Object.from_hash({:a => 1, :b => 42})
puts obj.a # 1
puts obj.b # 42
13 14 15 |
# File 'lib/nimo/utils/object_extension.rb', line 13 def self.from_hash(hash) OpenStruct.new(hash) end |