提交 c7adc961 编写于 作者: J Josep M. Bach 提交者: Xavier Noria

Documented active_support/configurable

上级 ca87d0a3
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/delegation'
module ActiveSupport module ActiveSupport
# Configurable provides a <tt>config</tt> method to store and retrieve
# configuration options as an <tt>OrderedHash</tt>.
module Configurable module Configurable
extend ActiveSupport::Concern extend ActiveSupport::Concern
...@@ -29,8 +31,25 @@ def #{name}=(value); config.#{name} = value; end ...@@ -29,8 +31,25 @@ def #{name}=(value); config.#{name} = value; end
end end
end end
# Reads and writes attributes from a configuration <tt>OrderedHash</tt>.
#
# 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
#
def config def config
@_config ||= ActiveSupport::InheritableOptions.new(self.class.config) @_config ||= ActiveSupport::InheritableOptions.new(self.class.config)
end end
end end
end end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册