Re:Kicking the Tires on Ruby 2.1 Preview
by ssmoot on Thursday September 26, 2013 @12:51PM
(#6451981)
You could always extend the singleton object before to avoid global monkey-patching.
But the real lesson is probably just if you're not writing ActiveSupport, don't do global monkey patches at all. Favor inheritance and composition. Especially in your own libraries where it's easier to ensure a global patch doesn't break your code.
Re:Kicking the Tires on Ruby 2.1 Preview
by dragonwriter on Thursday September 26, 2013 @02:02PM
(#6452487)
> My understanding is that refinements are more of a limitation of existing monkeypatching functionality though.
They are an alternative rather than a limitation, since you can still do regular monkeypatching, you just now have an option to do things that are less intrusive.
Re:Kicking the Tires on Ruby 2.1 Preview
by dewind on Thursday September 26, 2013 @01:49PM
(#6452384)
I'll refer to Nutter on this one. Refinements appear to be a method caching nightmare.
Re:Kicking the Tires on Ruby 2.1 Preview
by dragonwriter on Thursday September 26, 2013 @02:01PM
(#6452476)
Those concerns voiced with 2.0's refinements before release were why they were marked as experimental, and were the driving force behind the changes made to refinements between 2.0 and 2.1.
On the 2.1, non-experimental version, he has said: "What we’re going to have as refinements in 2.1 is a paired down version that I think still provides the bulk of the functionality people wanted out of the feature without most of the pain that I was concerned about originally."
Then again, many of the major gems that I've worked with so far define methods in various dynamic ways, making it challenging to figure out what code it's actually running. Hello ActiveRecord?