diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-29 14:56:19 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-29 14:56:19 -0700 |
commit | c19acab866a48d57655132f33ab224b59d87685b (patch) | |
tree | 8f95283fe64859b13047ffcbc6f5f14b7b181258 /activemodel/lib | |
parent | f7ccfdc0c452310811ef21bb00ccf06bbe1280f0 (diff) | |
parent | 569fb1fffb216ad96721fe1f5d706535e9920154 (diff) | |
download | rails-c19acab866a48d57655132f33ab224b59d87685b.tar.gz rails-c19acab866a48d57655132f33ab224b59d87685b.tar.bz2 rails-c19acab866a48d57655132f33ab224b59d87685b.zip |
Merge pull request #6062 from marcandre/tweak_observer
Tweak observer
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/observing.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index 35b1a1f0c7..cc60c9ac72 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -90,14 +90,15 @@ module ActiveModel def instantiate_observer(observer) #:nodoc: # string/symbol if observer.respond_to?(:to_sym) - observer.to_s.camelize.constantize.instance - elsif observer.respond_to?(:instance) + observer = observer.to_s.camelize.constantize + end + if observer.respond_to?(:instance) observer.instance else raise ArgumentError, - "#{observer} must be a lowercase, underscored class name (or an " + - "instance of the class itself) responding to the instance " + - "method. Example: Person.observers = :big_brother # calls " + + "#{observer} must be a lowercase, underscored class name (or " + + "the class itself) responding to the method :instance. " + + "Example: Person.observers = :big_brother # calls " + "BigBrother.instance" end end |