diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-28 09:21:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-28 09:21:58 +0000 |
commit | 7cf7ca79c71b361fe84d3f5243350f81f53ff3ff (patch) | |
tree | 7c7f6a770c6bc0e932aa2b0cdd3490501ae20856 /lib | |
parent | 131eb749c6b44172501171e77151acff782c7a9b (diff) | |
download | ruby-7cf7ca79c71b361fe84d3f5243350f81f53ff3ff.tar.gz |
ostruct.rb: refine visibility failure message
* lib/ostruct.rb (method_missing): raise an exception with proper
visibility message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ostruct.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 791471391c..25ccac8dfa 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -208,15 +208,18 @@ class OpenStruct raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1) end modifiable?[new_ostruct_member!(mname)] = args[0] - elsif len == 0 + elsif len == 0 # and /\A[a-z_]\w*\z/ =~ mid # if @table.key?(mid) new_ostruct_member!(mid) unless frozen? @table[mid] end else - err = NoMethodError.new "undefined method `#{mid}' for #{self}", mid, args - err.set_backtrace caller(1) - raise err + begin + super + rescue NoMethodError => err + err.backtrace.shift + raise + end end end |