Refinements

Refinements</
a> are similar to the namespace approach proposed long ago. The key
difference being #using to active the patches. Based on the older
idea, I wonder if the #refine method is actually necessary. Would this
not do as well?

module TimeExtensions
class Fixnum
def minutes; self * 60; end
end
end

class MyApp
using TimeExtensions

def initialize
  p 2.minutes
end

end

I’m not really sure I see a useful distinction from DelegateClass. How
is:

module Foo
  refine Bar do
    def baz; ...; end
  end
end

really that different from:

module Foo
  class Bar < DelegateClass(::Bar)
    def baz; ...; end
  end
end

except for a slightly more terse syntax?

On Nov 29, 11:20pm, Tony A. [email protected] wrote:

module Foo
class Bar < DelegateClass(::Bar)
def baz; …; end
end
end

except for a slightly more terse syntax?

Why even use DelegateClass ?

 module Foo
   class Bar < ::Bar
     def baz; ...; end
   end
 end

And it’s a good question (this is exactly the namespace idea that was
proposed long ago, btw). The only thing in the way of doing this is
Ruby’s lack of support for literals. That is to say, if I created an
extended String, Foo::String, then literal string notation within the
scope of Foo should use that. But I am guessing their are possible
subtitles I am missing. Can any one fill us in?