Ruby 1.9 will soon get a better way to monkey patch classes. Read all about them in Refinements in Ruby!
Comments
This is exciting stuff. Finally! This is very similar to the namespace approach I and other proposed long ago. The key difference being #using to active the patches. Based on those old ideas, 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
Comments
This is exciting stuff. Finally! This is very similar to the namespace approach I and other proposed long ago. The key difference being #using to active the patches. Based on those old ideas, I wonder if the #refine method is actually necessary. Would this not do as well?
I like it!
This is VERY promising
Post a comment