Documented active_support/configurable

This commit is contained in:
Josep M. Bach 2010-08-14 17:01:11 +02:00 committed by Xavier Noria
parent ca87d0a395
commit c7adc96186
1 changed files with 20 additions and 1 deletions

View File

@ -4,6 +4,8 @@ require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/delegation'
module ActiveSupport
# Configurable provides a <tt>config</tt> method to store and retrieve
# configuration options as an <tt>OrderedHash</tt>.
module Configurable
extend ActiveSupport::Concern
@ -29,8 +31,25 @@ module ActiveSupport
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
@_config ||= ActiveSupport::InheritableOptions.new(self.class.config)
end
end
end
end