Samiron
2010-May-09 06:28 UTC
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. http://digs.by/9Rezfs. Could you please share your thoughts about this implementation? Have a great time :) Take care. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter De Berdt
2010-May-09 18:39 UTC
Re: Decorator pattern in Ruby... what do you think about the implementation?
On 09 May 2010, at 08:28, Samiron wrote:> I was wondering about how you guys are implementing the decorator > patterns in Ruby? Here is a thought to share with. http://digs.by/9Rezfs > . > Could you please share your thoughts about this implementation?You could easily do that in a few lines: http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html 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) :-) Best regards Peter De Berdt -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2010-May-09 18:54 UTC
Re: Decorator pattern in Ruby... what do you think about the implementation?
On 9 May 2010 19:39, Peter De Berdt <peter.de.berdt-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote:> 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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter De Berdt
2010-May-09 19:19 UTC
Re: Decorator pattern in Ruby... what do you think about the implementation?
On 09 May 2010, at 20:54, Michael Pavling wrote:> On 9 May 2010 19:39, Peter De Berdt <peter.de.berdt-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote: >> 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.Agreed. Best regards Peter De Berdt -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Samiron
2010-May-10 06:19 UTC
Re: Decorator pattern in Ruby... what do you think about the implementation?
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) :D and of course need to thoughts to share. Samiron paul http://samironpaul.blogspot.com On May 10, 1:19 am, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote:> On 09 May 2010, at 20:54, Michael Pavling wrote: > > > On 9 May 2010 19:39, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote: > >> 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 moreresilient > > 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. > > Agreed. > > Best regards > > Peter De Berdt > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.