Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Added support for custom notify_observers() calls #8

Merged
merged 2 commits into from Apr 28, 2012

Conversation

dbalatero
Copy link
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!

Any call to notify_observers(:my_custom_message) will now be intercepted
in the way you'd expect.
@andycroll
Copy link

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

@kevTheDev
Copy link

+1

@dbalatero
Copy link
Contributor Author

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

State machine was the exact reason I added this :)

@dbalatero
Copy link
Contributor Author

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
Copy link
Contributor Author

(but this should be mergeable as is!)

patmaddox pushed a commit that referenced this pull request Apr 28, 2012
Added support for custom notify_observers() calls
@patmaddox patmaddox merged commit a0978d5 into patmaddox:master Apr 28, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants