diff options
author | Matthew Draper <matthew@trebex.net> | 2017-10-10 07:10:37 +1030 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-10 07:10:37 +1030 |
commit | 1b36e2cc244d34f4f232ef5abecdf12731f5ccfd (patch) | |
tree | e0ddd5397fdc3fc97fdfe7c2e3208afeb9a5f6c0 /activerecord | |
parent | 3564cd96045e62a7ea524f2f686c7a180badb6fa (diff) | |
parent | fb800feeea8b9cba38c8f616b8c7814e090b2905 (diff) | |
download | rails-1b36e2cc244d34f4f232ef5abecdf12731f5ccfd.tar.gz rails-1b36e2cc244d34f4f232ef5abecdf12731f5ccfd.tar.bz2 rails-1b36e2cc244d34f4f232ef5abecdf12731f5ccfd.zip |
Merge pull request #30836 from shioyama/generated_attribute_methods_include_mutex
Include Mutex_m into GeneratedAttributeMethods instead of extending instance
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index e4ca6c8408..891e556dc4 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -33,7 +33,9 @@ module ActiveRecord BLACKLISTED_CLASS_METHODS = %w(private public protected allocate new name parent superclass) - class GeneratedAttributeMethods < Module; end # :nodoc: + class GeneratedAttributeMethods < Module #:nodoc: + include Mutex_m + end module ClassMethods def inherited(child_class) #:nodoc: @@ -42,7 +44,7 @@ module ActiveRecord end def initialize_generated_modules # :nodoc: - @generated_attribute_methods = GeneratedAttributeMethods.new { extend Mutex_m } + @generated_attribute_methods = GeneratedAttributeMethods.new @attribute_methods_generated = false include @generated_attribute_methods diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 2d67c57cfb..2f42684212 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -999,6 +999,11 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_equal ["title"], model.accessed_fields end + test "generated attribute methods ancestors have correct class" do + mod = Topic.send(:generated_attribute_methods) + assert_match %r(GeneratedAttributeMethods), mod.inspect + end + private def new_topic_like_ar_class(&block) |