Skip to content

Commit 252ff50

Browse files
committed
Handling hash attributes in method_missing
1 parent 30327ee commit 252ff50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/ostruct.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def method_missing(mid, *args) # :nodoc:
202202
if len != 1
203203
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
204204
end
205-
modifiable?[new_ostruct_member!(mname)] = args[0]
205+
modifiable?[new_ostruct_member!(mname)] = args[0].is_a?(Hash) ? OpenStruct.new(args[0]) : args[0]
206206
elsif len == 0 # and /\A[a-z_]\w*\z/ =~ mid #
207207
if @table.key?(mid)
208208
new_ostruct_member!(mid) unless frozen?

0 commit comments

Comments
 (0)