Permalink
Browse files

Documented active_support/configurable

  • Loading branch information...
1 parent b517556 commit 25145d6f5f173dbba2945ab2b4fffa5a67785bb5 @txus txus committed Aug 14, 2010
Showing with 20 additions and 1 deletion.
  1. +20 −1 activesupport/lib/active_support/configurable.rb
@@ -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
@@ -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.