Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handling hash attributes in method_missing
  • Loading branch information
abhionlyone committed Oct 10, 2018
commit 252ff50ad2f3c2b6f9d3d19a9aa4815f2dcf3614
2 changes: 1 addition & 1 deletion lib/ostruct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def method_missing(mid, *args) # :nodoc:
if len != 1
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
end
modifiable?[new_ostruct_member!(mname)] = args[0]
modifiable?[new_ostruct_member!(mname)] = args[0].is_a?(Hash) ? OpenStruct.new(args[0]) : args[0]
elsif len == 0 # and /\A[a-z_]\w*\z/ =~ mid #
if @table.key?(mid)
new_ostruct_member!(mid) unless frozen?
Expand Down