File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
activesupport/lib/active_support Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,19 @@ def #{key}; _get(#{key.inspect}); end
27
27
end
28
28
29
29
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
30
43
def config
31
44
@_config ||= if respond_to? ( :superclass ) && superclass . respond_to? ( :config )
32
45
superclass . config . inheritable_copy
@@ -36,6 +49,21 @@ def config
36
49
end
37
50
end
38
51
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
39
67
def configure
40
68
yield config
41
69
end
You can’t perform that action at this time.
0 commit comments