Added support for custom notify_observers() calls #8

Merged
merged 2 commits into from Apr 28, 2012

Projects

None yet

4 participants

@dbalatero
Contributor

Hey Pat,

Prior to this commit, any custom notification calls you set up would not get disabled by the gem. Example:

class Car < ActiveRecord::Base
  def start!
    notify_observers(:started)
  end
end

class CarStartObserver < ActiveRecord::Observer
  def started(car)
    puts 'vrooooommmm'
  end
end

disable_observers
car = Car.new
car.start!  # => "vroooooommmmmm', doh!

This commit adds support for this disabling case in a (hopefully) minimal way!

dbalatero added some commits May 29, 2011
@dbalatero dbalatero Ignore vim swap files. 3eda8e4
@dbalatero dbalatero Support for intercepting custom notifications.
Any call to notify_observers(:my_custom_message) will now be intercepted
in the way you'd expect.
4c97f5d
@andycroll

Please implement this... super useful when working with state_machine observer callbacks

@kevTheDev

+1

@dbalatero
Contributor

Please implement this... super useful when working with state_machine observer callbacks

State machine was the exact reason I added this :)

@dbalatero
Contributor

Feel free to point at @ohwillie's branch at http://github.com/ohwillie/no-peeping-toms, which is what our team uses in our production app. It includes this fix + a couple more merged in from @patmaddox's master.

@dbalatero
Contributor

(but this should be mergeable as is!)

@patmaddox patmaddox merged commit a0978d5 into patmaddox:master Apr 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment