Just added the possibility to ignore events permanently:
ArEventComment.ignore_ar_events(:before_create)
#some code
ArEventComment.ignore_ar_events(:before_create)
or with a block of code:
ArEventComment.ignore_ar_events(:before_create) do
#some code
end
The code is on github: http://github.com/raphinou/ArEvents
Raph
On Thu, Dec 3, 2009 at 5:19 PM, Raphael Bauduin
<rblists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I needed to be able to add actions to be taken during the lifecycle of
> ActiveRecord object, but needed to configure it dynamically.
> Observers were not flexible enough and I ended up developing ArEvents,
> which lets you easily attach and detach event listeners, the events
> correspond to the active record callbacks.
>
> If you have an existing model, just include the ArEvents module:
>
> ArEventComment.send(:include, ArEvents)
>
> and you can then add event listeners:
>
> ArEventComment.add_ar_event_listener(:before_validation,
ArEventCommentListener)
>
> An event listener is simply a class with a class method named trigger
> that takes 2 arguments: the event fired and the object fireing the
> event:
>
> class ArEventCommentListener
> def self.trigger(evt, obj)
> puts "event #{evt} triggered by object #{obj.inspect}"
> end
> end
>
>
> I''m not yet using it in production, but tests pass as expected.
>
> You can find the code at http://github.com/raphinou/ArEvents
>
> All comments and suggestions are of course welcome!
>
> Raphaël
>
>
> --
> Web database: http://www.myowndb.com
> Free Software Developers Meeting: http://www.fosdem.org
>
--
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org
--
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.