Decorator pattern in Ruby... what do you think about the implementation?

Hello all
I was wondering about how you guys are implementing the decorator
patterns in Ruby? Here is a thought to share with.
Could you please share your thoughts about this implementation?

Have a great time :slight_smile:
Take care.

You could easily do that in a few lines:

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) :slight_smile:

Best regards

Peter De Berdt

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.


Best regards

Peter De Berdt

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) :smiley: and of course need to thoughts to share.

Samiron paul