mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added that Observers can use the observes class method instead of overwriting self.observed_class()
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@367 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
d239ac40fa
commit
d5de666056
1 changed files with 5 additions and 1 deletions
|
@ -43,7 +43,11 @@ module ActiveRecord
|
|||
# The observer can implement callback methods for each of the methods described in the Callbacks module.
|
||||
class Observer
|
||||
include Singleton
|
||||
|
||||
|
||||
def self.observe(*models)
|
||||
define_method(:observed_class) { models }
|
||||
end
|
||||
|
||||
def initialize
|
||||
[ observed_class ].flatten.each do |klass|
|
||||
klass.add_observer(self)
|
||||
|
|
Loading…
Reference in a new issue