static public Method

Observer.observed_class

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

assert_equal [Person], PersonObserver.observed_class

Source Code

# File active_record/observer.rb, line 155
def observed_class
  if observed_class_name = name.scan(/(.*)Observer/)[0]
    observed_class_name[0].constantize
  else
    nil
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.