提交 8fd69db7 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #29788 from kamipo/remove_unused_mutex_m

Remove unused `Mutex_m` in Active Model
# frozen_string_literal: true
require "concurrent/map"
require "mutex_m"
module ActiveModel
# Raised when an attribute is not defined.
......@@ -329,13 +328,11 @@ def undefine_attribute_methods
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
......
......@@ -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
......
......@@ -8,11 +8,10 @@ def type; :integer; end
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
......
......@@ -1005,7 +1005,7 @@ def new_topic_like_ar_class(&block)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册