In message "Re: [ruby-core:50412] [ruby-trunk - Feature #4085] Refinements and nested methods"
    on Sat, 1 Dec 2012 04:54:20 +0900, "headius (Charles Nutter)" <headius / headius.com> writes:

|However, you go on to say that the example below should work, and I don't understand why:
|
|module R
|  refine String do
|    def foo; p :foo; end
|  end
|
|  module M
|    refine(Array) { ... }
|    "".foo
|  end
|  "".foo
|end
|"".foo
|
|Nothing has changed here; none of the foo calls are within refine blocks, but your example indicates the innermost foo should work. Why?

I don't think I did.  I meant:

>module R
>  refine String do
>    def foo; p :foo; end
>  end
>
>  module M
>    refine(Array) {
>      "".foo
>    }
>  end
>end
>using R
>"".foo

|This shouldn't work anyway. Why would we look at refinements for Integer if Fixnum has overridden those methods? This seems completely anti-OO to me. Are you saying refinements can route completely around overridden methods without touching the class that overrides them?

If you think it's anti OO, you are too influenced by Java OO.  Think
of CLOS's around methods.  I want refinements to be method decorators.

							matz.