Module: OpenStruct::FromHash
- Included in:
- OpenStruct
- Defined in:
- lib/llm/core_ext/ostruct.rb
Instance Method Summary collapse
-
#from_hash(hash_obj) ⇒ OpenStruct
An OpenStruct object initialized by visiting
hash_obj
with recursion.
Instance Method Details
#from_hash(hash_obj) ⇒ OpenStruct
Returns An OpenStruct object initialized by visiting hash_obj
with
recursion.
16 17 18 19 20 21 22 |
# File 'lib/llm/core_ext/ostruct.rb', line 16 def from_hash(hash_obj) visited_object = {} hash_obj.each do |key, value| visited_object[key] = walk(value) end OpenStruct.new(visited_object) end |