aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/observer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/observer.rb')
-rw-r--r--activerecord/lib/active_record/observer.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index ed0f039597..0ea7fe7365 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/activerecord/lib/active_record/observer.rb
@@ -88,7 +88,7 @@ module ActiveRecord
#
class Observer < ActiveModel::Observer
class_attribute :observed_methods
- self.observed_methods = []
+ self.observed_methods = [].freeze
def initialize
super
@@ -97,7 +97,11 @@ module ActiveRecord
def self.method_added(method)
method = method.to_sym
- observed_methods << method if ActiveRecord::Callbacks::CALLBACKS.include?(method)
+
+ if ActiveRecord::Callbacks::CALLBACKS.include?(method)
+ self.observed_methods += [method]
+ self.observed_methods.freeze
+ end
end
protected