I
Intransition
<a href="http://timeless.judofyr.net/refinements-in-ruby">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
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