【发布时间】:2011-02-05 13:26:27
【问题描述】:
据我了解,super 关键字调用的方法与当前类的超类中的当前方法同名。在autoload 方法的下方,有一个对super 的调用。我想知道我会在哪个超类中找到同名的方法,或者在这里调用super 做了什么
module ActiveSupport
module Autoload
...
def autoload(const_name, path = @@at_path)
full = [self.name, @@under_path, const_name.to_s, path].compact.join("::")
location = path || Inflector.underscore(full)
if @@eager_autoload
@@autoloads[const_name] = location
end
super const_name, location
end
....
end
end
module ActiveRecord
extend ActiveSupport::Autoload
...
autoload :TestCase
autoload :TestFixtures, 'active_record/fixtures'
end
此代码来自 rails master 分支。非常感谢。
【问题讨论】:
标签: ruby-on-rails ruby activerecord