Permalink
Browse files

Observers can observe model names as symbols properly now. Closes #9869

… [queso]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7872 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
technoweenie committed Oct 14, 2007
1 parent a9eaa25 commit f56dd107cdecb3cbffa04c320b4c30317331143d
Showing with 5 additions and 2 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +2 −1 activerecord/lib/active_record/observer.rb
  3. +1 −1 activerecord/test/lifecycle_test.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Observers can observe model names as symbols properly now. Closes #9869 [queso]
+
* find_and_(initialize|create)_by methods can now properly initialize protected attributes [Tobias Luetke]
* belongs_to infers the foreign key from the association name instead of from the class name. [Jeremy Kemper]
@@ -131,7 +131,8 @@ class Observer
class << self
# Attaches the observer to the supplied model classes.
def observe(*models)
- models.flatten.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model }
+ models.flatten!
+ models.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model }
define_method(:observed_classes) { Set.new(models) }
end
@@ -27,7 +27,7 @@ def has_been_notified?
end
class TopicaObserver < ActiveRecord::Observer
- def self.observed_class() Topic end
+ observe :topic
attr_reader :topic

0 comments on commit f56dd10

Please sign in to comment.