diff options
author | Chris Salzberg <chris@dejimata.com> | 2019-03-13 10:17:00 +0900 |
---|---|---|
committer | Chris Salzberg <chris@dejimata.com> | 2019-03-13 10:34:15 +0900 |
commit | 8ca3c286a768038f6b391fd3bfbdfcc299876a1f (patch) | |
tree | ae93f15965fad583bcd749d13a5e70ffd79876d9 /activerecord/test/cases | |
parent | 963ec3bae5ac12ab3e0614bdd0d0ca9fba06ac46 (diff) | |
download | rails-8ca3c286a768038f6b391fd3bfbdfcc299876a1f.tar.gz rails-8ca3c286a768038f6b391fd3bfbdfcc299876a1f.tar.bz2 rails-8ca3c286a768038f6b391fd3bfbdfcc299876a1f.zip |
Give GeneratedAttributeMethods module a name
Currently GeneratedAttributeMethods is a module builder class, an
instance of which is included in every AR class. OTOH,
GeneratedAssociatedMethods is assigned to a constant under the model
namespace. This is inconsistent and looks strange in the list of
ancestors.
There is no particular reason *not* to assign a constant for this (very
important) module under the model namespace, so that's what this commit
does.
Previous to this change, ancestors for an AR class looked like this:
```
=> [User (call 'User.connection' to establish a connection),
User::GeneratedAssociationMethods,
#<ActiveRecord::AttributeMethods::GeneratedAttributeMethods:0x000055ace0f05b08>,
ApplicationRecord(abstract),
ApplicationRecord::GeneratedAssociationMethods,
#<ActiveRecord::AttributeMethods::GeneratedAttributeMethods:0x000055ace093c460>,
ActiveRecord::Base,
...
```
With this change, they look like this:
```
=> [User (call 'User.connection' to establish a connection),
User::GeneratedAssociationMethods,
User::GeneratedAttributeMethods,
ApplicationRecord(abstract),
ApplicationRecord::GeneratedAssociationMethods,
ApplicationRecord::GeneratedAttributeMethods,
ActiveRecord::Base,
...
```
The previously named `GeneratedAttributeMethods` module builder class is
renamed `GeneratedAttributeMethodsBuilder` to emphasize that this is not
a module but a class.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index f51c87ef2b..9fd62dcf72 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -1083,7 +1083,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase test "generated attribute methods ancestors have correct class" do mod = Topic.send(:generated_attribute_methods) - assert_match %r(GeneratedAttributeMethods), mod.inspect + assert_match %r(Topic::GeneratedAttributeMethods), mod.inspect end private |