Skip to content

Commit

Permalink
Added a little bit more docs on ObserverArray
Browse files Browse the repository at this point in the history
  • Loading branch information
smartinez87 committed Apr 28, 2011
1 parent 533efd8 commit 505108b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion activemodel/lib/active_model/observer_array.rb
Expand Up @@ -13,10 +13,12 @@ def self.for(model_class)
INSTANCES[model_class] INSTANCES[model_class]
end end


# returns false if: # Returns false if:
# - the ObserverArray for the given model's class has the given observer # - the ObserverArray for the given model's class has the given observer
# in its disabled_observers set. # in its disabled_observers set.
# - or that is the case at any level of the model's superclass chain. # - or that is the case at any level of the model's superclass chain.
#
# On other cases it returns true, since observers are enabled by default.
def self.observer_enabled?(observer, model) def self.observer_enabled?(observer, model)
klass = model.class klass = model.class
observer_class = observer.class observer_class = observer.class
Expand All @@ -40,10 +42,12 @@ def initialize(model_class, *args)
super(*args) super(*args)
end end


# Disable the given observers.
def disable(*observers, &block) def disable(*observers, &block)
set_enablement(false, observers, &block) set_enablement(false, observers, &block)
end end


# Enable the given observers.
def enable(*observers, &block) def enable(*observers, &block)
set_enablement(true, observers, &block) set_enablement(true, observers, &block)
end end
Expand Down

0 comments on commit 505108b

Please sign in to comment.