Thanks all We have been using that suggested pattern for a while, service objects we call them. But for this particular case a event listener pattern made sense. But as this doesnt seem to be a popular/good practice in rails I will probably move that logic into service object as recommended.
Seb Sent from my Kindle Fire _____________________________________________ From: Krasimir Angelov <[email protected]> Sent: Wed Oct 31 17:56:45 GMT+11:00 2012 To: [email protected] Subject: [rails-oceania] Re: Hooks, observers, listeners Yeah, dedicated object to handle the business logic is what we do. You may take a look at Matt Wynne's Hexagonal Rails video - http://vimeo.com/44807822. K. On Wednesday, October 31, 2012 1:02:28 AM UTC+2, Sebastian Porto wrote: Hi All Someone please point me in the right direction with this. I would like to implement an event / listener pattern in parts of my application. But I don't quite like the Observer pattern as it is as it hides the flow, I will like something explicit, where you trigger events manually. See made up code below: class User < ActiveRecord::Base def something trigger :on_something, name end end class UserObserver < ActiveRecord::Observer def on_something(name) ... end end I have been looking at custom callbacks http://api.rubyonrails.org/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-define_callbacks Observers http://api.rubyonrails.org/classes/ActiveRecord/Observer.html But nothing quite does what I want, or I don't know how to hook it together. Any suggestions / gems on this will be appreciated. Thanks, Sebastian -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To view this discussion on the web visit https://groups.google.com/d/msg/rails-oceania/-/jjtyE8d2NAMJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
