Bug #12370
closedrequire 'mkmf' changes Object#respond_to? behaviour
Description
Replication steps:
$ irb
> RUBY_VERSION
=> '2.3.0'
> require 'yaml'
> YAML.public_method_defined?(:configuration)
=> false
> YAML.respond_to?(:configuration)
=> false
> require 'mkmf'
> YAML.public_method_defined?(:configuration)
=> false
> YAML.respond_to?(:configuration)
=> true
--Also there is a different behaviour for core classes over library or gem classes and/or modules under Object namespace.--
Wrong: It is a difference between modules and classes which is fine!
See below on update #8.
The changed behaviour is triggered by:
mkmf.rb:2718 =>
Updated by dsferreira (Daniel Ferreira) about 10 years ago
- Description updated (diff)
Updated by dsferreira (Daniel Ferreira) about 10 years ago
- Description updated (diff)
Updated by dsferreira (Daniel Ferreira) about 10 years ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
Updated by dsferreira (Daniel Ferreira) about 10 years ago
Hi Nobu.
I discovered due to this bug in capybara-screenshot gem: [[https://github.com/mattheworiordan/capybara-screenshot/issues/162]]
And your right. I also think they should not use
But when I say that Object#respond_to? behaviour was changed it is because of this:
When the definition of Object#respond_to? is that it will be true if public method exists.
So the behaviour is different for some reason.
For me that is a bug or we need to update the definition of the method itself.
Do you agree with me?
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Status changed from Open to Closed
Module#public_method_defined? is for instance methods.
Object#respond_to? is for its own methods.
They have no relationship.
Updated by dsferreira (Daniel Ferreira) about 10 years ago
Updated by dsferreira (Daniel Ferreira) about 10 years ago
In this situation we have Module#public_method_defined? returning different things for classes and modules which makes sense from its definition where it gets all ancestors when called in a class.
Ex:
Updated by dsferreira (Daniel Ferreira) about 10 years ago
- Description updated (diff)
Updated by usa (Usaku NAKAMURA) about 10 years ago
- Status changed from Closed to Rejected