diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-09-30 01:37:07 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-09-30 01:37:07 +0000 |
commit | 52547f53314a52de14d90befb90f4364d800671e (patch) | |
tree | b78319d19b0f9916929b06b20a32086c6db5f8a6 /activerecord/lib/active_record | |
parent | 25cce680134fb97cf2e2b5be03e0043272eaa710 (diff) | |
download | rails-52547f53314a52de14d90befb90f4364d800671e.tar.gz rails-52547f53314a52de14d90befb90f4364d800671e.tar.bz2 rails-52547f53314a52de14d90befb90f4364d800671e.zip |
Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5211 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/observer.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb index b472423b88..ace52ef415 100644 --- a/activerecord/lib/active_record/observer.rb +++ b/activerecord/lib/active_record/observer.rb @@ -18,10 +18,18 @@ module ActiveRecord # # # Same as above, just using explicit class references # ActiveRecord::Base.observers = Cacher, GarbageCollector + # + # Note: Setting this does not instantiate the observers yet. #instantiate_observers is + # called during startup, and before each development request. def observers=(*observers) @observers = observers.flatten end + # Gets the current observers. + def observers + @observers ||= [] + end + # Instantiate the global ActiveRecord observers def instantiate_observers return if @observers.blank? |