方法
实例公有方法
initializer(name, opts = {}, &blk) 链接
源代码: 显示 | 在 GitHub 上
# File railties/lib/rails/initializable.rb, line 88 def initializer(name, opts = {}, &blk) raise ArgumentError, "A block must be passed when defining an initializer" unless blk opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] } initializers << Initializer.new(name, nil, opts, &blk) end
initializers() 链接
源代码: 显示 | 在 GitHub 上
# File railties/lib/rails/initializable.rb, line 71 def initializers @initializers ||= Collection.new end
initializers_chain() 链接
源代码: 显示 | 在 GitHub 上
# File railties/lib/rails/initializable.rb, line 75 def initializers_chain initializers = Collection.new ancestors.reverse_each do |klass| next unless klass.respond_to?(:initializers) initializers = initializers + klass.initializers end initializers end
initializers_for(binding) 链接
源代码: 显示 | 在 GitHub 上
# File railties/lib/rails/initializable.rb, line 84 def initializers_for(binding) Collection.new(initializers_chain.map { |i| i.bind(binding) }) end