Active Support 可設定
Configurable
提供 config
方法,用於儲存和擷取設定選項,為 OrderedOptions
。
命名空間
方法
- C
執行個體公開方法
config() 連結
從設定 OrderedOptions
讀取和寫入屬性。
require "active_support/configurable"
class User
include ActiveSupport::Configurable
end
user = User.new
user.config.allowed_access = true
user.config.level = 1
user.config.allowed_access # => true
user.config.level # => 1
來源: 顯示 | 在 GitHub 上
# File activesupport/lib/active_support/configurable.rb, line 155 def config @_config ||= self.class.config.inheritable_copy end