From: kurtis@... Date: 2018-03-07T17:35:08+00:00 Subject: [ruby-core:85982] [Ruby trunk Bug#14583] #method() is reporting the wrong self in lookup Issue #14583 has been reported by krainboltgreene (Kurtis Rainbolt-Greene). ---------------------------------------- Bug #14583: #method() is reporting the wrong self in lookup https://bugs.ruby-lang.org/issues/14583 * Author: krainboltgreene (Kurtis Rainbolt-Greene) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- This is hard to explain but I'll do my best: When running an rspec test I get this exception: ~~~ Failure/Error: resource_class.write_attributes_via_call(model, attributes.select(&resource.method(:valid_attribute?))) NameError: undefined method `valid_attribute?' for class `PhotoRealizer' Did you mean? alias_attribute ~~~ This is unequivocally wrong, so I go to prove it: ~~~ 13: def call 14: resource.model.tap do |model| 15: resource_class.write_attributes_via_call(model, {id: id}) if id => 16: binding.pry 17: resource_class.write_attributes_via_call(model, attributes.select(&resource.method(:valid_attribute?))) 18: resource_class.write_attributes_via_call(model, relationships.select(&resource.method(:valid_relationship?)).transform_values(&resource.method(:as_relationship))) 19: resource_class.save_via_call(model) 20: end 21: end [1] pry(#)> resource => #> [2] pry(#)> resource.class => PhotoRealizer [3] pry(#)> resource.class.valid_attribute? ArgumentError: wrong number of arguments (given 0, expected 2) ~~~ Turns out however, that I'm being silly and calling `method()` on an instance, so I exit out of my pry: ``` Failure/Error: resource_class.write_attributes_via_call(model, attributes.select(&resource.method(:valid_attribute?))) NameError: undefined method `valid_attribute?' for class `#>' Did you mean? alias_attribute ``` Wait, what? How could this be? A different error now that I've observed? -- https://bugs.ruby-lang.org/ Unsubscribe: