Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a little bit more docs on ObserverArray #339

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion activemodel/lib/active_model/observer_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ def self.for(model_class)
INSTANCES[model_class]
end

# returns false if:
# Returns false if:
# - the ObserverArray for the given model's class has the given observer
# in its disabled_observers set.
# - 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)
klass = model.class
observer_class = observer.class
Expand All @@ -40,10 +42,12 @@ def initialize(model_class, *args)
super(*args)
end

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

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