Issue #15409 has been updated by oleynikov (Alexander Oleynikov).


According to the docs, `OpenStruct` uses `method_missing`, so it does not redefine existing methods of `Object` or `BasicObject`.
https://docs.ruby-lang.org/en/trunk/OpenStruct.html

```ruby
o = OpenStruct.new(
  method:  'method',
  class:   'class',
  display: 'display',
  send:    'send',
  __id__:  '__id__',
  frozen?: 'frozen?'
)

o.method  #=> ArgumentError (wrong number of arguments (given 0, expected 1))
o.class   #=> OpenStruct
o.display #=> #<OpenStruct method="method", class="class", display="display"...
o.send    #=> ArgumentError (no method name given)
o.__id__  #=> 7539827944720
o.frozen? #=> false
```

----------------------------------------
Bug #15409: OpenStruct error when attribute is called 'method'
https://bugs.ruby-lang.org/issues/15409#change-75649

* Author: elioncho (Elas Orozco)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
The following error is shown when you try to access an OpenStruct with a property called method:

`method': wrong number of arguments (given 0, expected 1) (ArgumentError)

To replicate:

~~~ ruby
require 'ostruct'
o = OpenStruct.new({ method: 'get' })
o.method
~~~


The expected behavior should be to return 'get'




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>