Methods defined in Refinements cannot be called via send
class C end module M refine C do def a() p:hello end def b() p:world end end end using M C.new.a C.new.send :b
% ruby -v t.rb ruby 2.3.0dev (2015-08-22 trunk 51660) [x86_64-darwin14] :hello t.rb:13:in `<main>': undefined method `b' for #<C:0x007f86c9a12af0> (NoMethodError)
Updated by shugo (Shugo Maeda) about 7 years ago
- Tracker changed from Bug to Feature
- Status changed from Open to Assigned
- Assignee changed from shugo (Shugo Maeda) to matz (Yukihiro Matsumoto)
It's an intended behavior that Kernel#send ignores refinements as described at https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpec
What do you think of it, Matz?
Updated by matz (Yukihiro Matsumoto) about 6 years ago
The current behavior is according to the direct interpretation of the refinement spec. But many people expect
send to be another form of a method call (including refinement). And now I agree with it.