方法
类公共方法
compile_methods!(keys) 链接
编译读取方法,这样我们就不用通过 method_missing 了。
来源: 显示 | 在 GitHub 上
# File activesupport/lib/active_support/configurable.rb, line 26 def self.compile_methods!(keys) keys.reject { |m| method_defined?(m) }.each do |key| class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{key}; _get(#{key.inspect}); end RUBY end end
实例公共方法
compile_methods!() 链接
来源: 显示 | 在 GitHub 上
# File activesupport/lib/active_support/configurable.rb, line 21 def compile_methods! self.class.compile_methods!(keys) end