Skip to content

Commit 9c62b0f

Browse files
committed
Document ActiveSupport::Configurable class methods
Add method-level documentation for the `ActiveSupport::Configurable.configure` block method and `ActiveSupport::Configurable.config` attribute reader method.
1 parent 2aa67ec commit 9c62b0f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

activesupport/lib/active_support/configurable.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ def #{key}; _get(#{key.inspect}); end
2727
end
2828

2929
module ClassMethods
30+
# Reads and writes attributes from a configuration OrderedOptions.
31+
#
32+
# require "active_support/configurable"
33+
#
34+
# class User
35+
# include ActiveSupport::Configurable
36+
# end
37+
#
38+
# User.config.allowed_access = true
39+
# User.config.level = 1
40+
#
41+
# User.config.allowed_access # => true
42+
# User.config.level # => 1
3043
def config
3144
@_config ||= if respond_to?(:superclass) && superclass.respond_to?(:config)
3245
superclass.config.inheritable_copy
@@ -36,6 +49,21 @@ def config
3649
end
3750
end
3851

52+
# Configure values from within the passed block.
53+
#
54+
# require "active_support/configurable"
55+
#
56+
# class User
57+
# include ActiveSupport::Configurable
58+
# end
59+
#
60+
# User.allowed_access # => nil
61+
#
62+
# User.configure do |config|
63+
# config.allowed_access = true
64+
# end
65+
#
66+
# User.allowed_access # => true
3967
def configure
4068
yield config
4169
end

0 commit comments

Comments
 (0)