Issue #7269 has been updated by shugo (Shugo Maeda).


matz (Yukihiro Matsumoto) wrote:
> OK, I understand the behavior.  What are pros and cons of module based refinement?

pros:

* not affected by the order of loading/using
* consistent with module_eval and behavior when a module is reopened (Bug #7271)

cons:

* might be hard to implement efficiently
  * especially super when refinements are cascaded might be hard to implement

----------------------------------------
Bug #7269: Refinement doesn't work if using locate after method
https://bugs.ruby-lang.org/issues/7269#change-32373

Author: ko1 (Koichi Sasada)
Status: Open
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-01 trunk 37404) [i386-mswin32_100]


Refinement doesn't work if using locate after method.
(I eliminate discussion because my laptop doesn't have enough power...)


class C
  def foo
    p :C_foo
  end
end

module M1
  refine C do
    def foo
      p :M1_foo
      super
    end
  end
end

module M2
  refine C do
    def foo
      p :M2_foo
      super
    end
  end
end

class D
  using M1

  def x
    C.new.foo
  end

  using M2
end

p :x
D.new.x

#=>
:x
:M1_foo
:C_foo



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