diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-07-17 13:54:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-17 13:54:37 -0400 |
commit | 8fd69db783b14dcdde92f4682b8d3c66bdbcb90b (patch) | |
tree | fbf40dd8d961ed0413c200b47f464b01b72ad7bd | |
parent | 5a8b430d5e7e72f19727c360abdb0ac6503d073c (diff) | |
parent | 12e6cba9cf5d2e29438751e0922b27d75da8b0c6 (diff) | |
download | rails-8fd69db783b14dcdde92f4682b8d3c66bdbcb90b.tar.gz rails-8fd69db783b14dcdde92f4682b8d3c66bdbcb90b.tar.bz2 rails-8fd69db783b14dcdde92f4682b8d3c66bdbcb90b.zip |
Merge pull request #29788 from kamipo/remove_unused_mutex_m
Remove unused `Mutex_m` in Active Model
4 files changed, 7 insertions, 11 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 7088435090..888a431e5f 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "concurrent/map" -require "mutex_m" module ActiveModel # Raised when an attribute is not defined. @@ -329,13 +328,11 @@ module ActiveModel attribute_method_matchers_cache.clear end - def generated_attribute_methods #:nodoc: - @generated_attribute_methods ||= Module.new { - extend Mutex_m - }.tap { |mod| include mod } - end - private + def generated_attribute_methods + @generated_attribute_methods ||= Module.new.tap { |mod| include mod } + end + def instance_method_already_implemented?(method_name) generated_attribute_methods.method_defined?(method_name) end diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 8d884ff26c..d2837ec894 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -118,7 +118,7 @@ class AttributeMethodsTest < ActiveModel::TestCase test "#define_attribute_method does not generate attribute method if already defined in attribute module" do klass = Class.new(ModelWithAttributes) - klass.generated_attribute_methods.module_eval do + klass.send(:generated_attribute_methods).module_eval do def foo "<3" end diff --git a/activerecord/test/cases/attribute_methods/read_test.rb b/activerecord/test/cases/attribute_methods/read_test.rb index 1fc63a49d4..934d5bf8b2 100644 --- a/activerecord/test/cases/attribute_methods/read_test.rb +++ b/activerecord/test/cases/attribute_methods/read_test.rb @@ -8,11 +8,10 @@ module ActiveRecord end def setup - @klass = Class.new do + @klass = Class.new(Class.new { def self.initialize_generated_modules; end }) do def self.superclass; Base; end def self.base_class; self; end def self.decorate_matching_attribute_types(*); end - def self.initialize_generated_modules; end include ActiveRecord::DefineCallbacks include ActiveRecord::AttributeMethods diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 4d24a980dc..366577761c 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -1005,7 +1005,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase class_eval(&block) end - assert_empty klass.generated_attribute_methods.instance_methods(false) + assert_empty klass.send(:generated_attribute_methods).instance_methods(false) klass end |