Skip to content

Commit

Permalink
Documented active_support/configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep M. Bach committed Aug 14, 2010
1 parent b517556 commit 25145d6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion activesupport/lib/active_support/configurable.rb
Expand Up @@ -4,6 +4,8 @@
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

Expand All @@ -29,8 +31,25 @@ def #{name}=(value); config.#{name} = value; 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
@_config ||= ActiveSupport::InheritableOptions.new(self.class.config)
end
end
end
end

0 comments on commit 25145d6

Please sign in to comment.