Thanks Phil. I like the way they put the Ruby core objects on a level playing field with your own application objects, and let them add the behaviour you want.
Having said that, I'd probably draw a line at doing anything like:
module EasyFinder
refine Integer do
def to_book
Book.find(self)
end
end
refine String do
def to_book
Book.find(self.to_i)
end
end
end
... if I thought anyone was ever going to see my code.
I like the semantics, but it's a bit "out there".
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice use of refinements. I've not seen them around much, but this is a good example of how they can really clean up an approach.
Thanks Phil. I like the way they put the Ruby core objects on a level playing field with your own application objects, and let them add the behaviour you want.
Having said that, I'd probably draw a line at doing anything like:
... if I thought anyone was ever going to see my code.
I like the semantics, but it's a bit "out there".