方法
類別公開方法
compile_methods!(keys) 連結
編譯讀取器方法,因此我們不必使用 method_missing。
來源: 顯示 | 在 GitHub 上
# File activesupport/lib/active_support/configurable.rb, line 20 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 15 def compile_methods! self.class.compile_methods!(keys) end