@@ -2,6 +2,47 @@ module ActiveRecord
2
2
module ApplicationConfiguration
3
3
extend ActiveSupport ::Concern
4
4
5
+ # The <tt>ApplicationConfiguration</tt> module allows you to control different
6
+ # configurations that have been set on a particular namespace or model. The
7
+ # <tt>ApplicationRecord</tt> class for a particular model can be accessed and used
8
+ # for finding configurations.
9
+ #
10
+ # To access this class, you can use the <tt>application_record</tt> method on
11
+ # any subclass of <tt>ActiveRecord::Base</tt>. For example:
12
+ #
13
+ # class MyModel < ApplicationRecord
14
+ # end
15
+ #
16
+ # ActiveRecord::Base.application_record # => ApplicationRecord
17
+ # MyModel.application_record # => ApplicationRecord
18
+ #
19
+ # Moreover, you can use namespacing of modules with the <tt>application_record</tt>
20
+ # method.
21
+ #
22
+ # module MyNamespace
23
+ # class ApplicationRecord < ::ApplicationRecord
24
+ # end
25
+ #
26
+ # class MyModel < ApplicationRecord
27
+ # end
28
+ # end
29
+ #
30
+ # ActiveRecord::Base.application_record # => ApplicationRecord
31
+ # MyNamespace::MyModel.application_record # => MyNamespace::ApplicationRecord
32
+ #
33
+ # You may additionally pass in a class to <tt>application_record</tt>, and
34
+ # it will look for the configuration of that class. For example:
35
+ #
36
+ # ActiveRecord::Base.application_record(MyNamespace::MyModel)
37
+ # # => MyNamespace::ApplicationRecord
38
+ #
39
+ # If the class that is passed into <tt>application_record</tt> does not have
40
+ # a configuration associated with it, then the method will return the value
41
+ # that would have been returned without any argument.
42
+ #
43
+ # ActiveRecord::Base.application_reocrd('something_with_no_config')
44
+ # # => ApplicationRecord
45
+ #
5
46
module ClassMethods
6
47
def configs_from ( mod )
7
48
app_record = self
0 commit comments