class method self.observed_class

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

self.observed_class()

The class observed by default is inferred from the observer’s class name:

assert_equal Person, PersonObserver.observed_class
Source
# File activerecord/lib/active_record/observer.rb, line 155
      def observed_class
        if observed_class_name = name[/(.*)Observer/, 1]
          observed_class_name.constantize
        else
          nil
        end
      end

Defined in activerecord/lib/active_record/observer.rb line 155 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Observer

Type at least 2 characters to search.

↑↓ navigate · open · esc close