Hello all
I was wondering about how you guys are implementing the decorator
patterns in Ruby? Here is a thought to share with. Tagged - The social network for meeting new people.
Could you please share your thoughts about this implementation?
There are quite a few blog posts on the net when you google for “ruby decorator pattern”.
About your implementation, I prefer the syntax from the post above, simply because it reads more natural. Other than that, yours does seem a viable solution (only skimmed it, but seems fine)
It's an interesting pure Ruby implementation, but it's not a great
Rails implementation, because it's overloading "method_missing"
without a call to super.
To be a bit more resilient, I'd add a check that @decorated responds
to the method before sending, and then call super to let Rails get on
with any of its magic that you might be fubaring otherwise.
Hello Peter and Michael,
Thanks for your comments. Keep tuned up with my blog. I will be
investigating on more design patterns to implement in Ruby (not in
Rails style) and of course need to thoughts to share.