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
endexcept 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?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs