Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/brick/monkey_patches/hash.rb
Instance Method Summary collapse
Instance Method Details
#to_ostruct ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/brick/monkey_patches/hash.rb', line 4 def to_ostruct ostruct = inject({}) {|result, (key, value)| if value.is_a?(Array) value = value.map {|v| v.respond_to?(:to_ostruct) ? v.to_ostruct : v } end result[key] = value.respond_to?(:to_ostruct) ? value.to_ostruct : value result } OpenStruct.new(ostruct) end |