Skip to content

Commit f7e179f

Browse files
committed
Remove some sends
1 parent 6701647 commit f7e179f

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

activemodel/lib/active_model/attribute_registration.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ def type_for_attribute(attribute_name, &block)
5050
end
5151
end
5252

53+
def apply_pending_attribute_modifications(attribute_set) # :nodoc:
54+
if superclass.respond_to?(:apply_pending_attribute_modifications, true)
55+
superclass.send(:apply_pending_attribute_modifications, attribute_set)
56+
end
57+
58+
pending_attribute_modifications.each do |modification|
59+
modification.apply_to(attribute_set)
60+
end
61+
end
62+
5363
private
5464
PendingType = Struct.new(:name, :type) do # :nodoc:
5565
def apply_to(attribute_set)
@@ -78,16 +88,6 @@ def pending_attribute_modifications
7888
@pending_attribute_modifications ||= []
7989
end
8090

81-
def apply_pending_attribute_modifications(attribute_set)
82-
if superclass.respond_to?(:apply_pending_attribute_modifications, true)
83-
superclass.send(:apply_pending_attribute_modifications, attribute_set)
84-
end
85-
86-
pending_attribute_modifications.each do |modification|
87-
modification.apply_to(attribute_set)
88-
end
89-
end
90-
9191
def reset_default_attributes
9292
reset_default_attributes!
9393
subclasses.each { |subclass| subclass.send(:reset_default_attributes) }

activerecord/lib/active_record/attributes.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ def attribute_types # :nodoc:
258258
model_schema.attribute_types
259259
end
260260

261+
def type_for_column(column) # :nodoc:
262+
hook_attribute_type(column.name, super)
263+
end
264+
261265
##
262266
# :method: type_for_attribute
263267
# :call-seq: type_for_attribute(attribute_name, &block)
@@ -303,10 +307,6 @@ def reset_default_attributes
303307
def resolve_type_name(name, **options)
304308
Type.lookup(name, **options, adapter: Type.adapter_name_from(self))
305309
end
306-
307-
def type_for_column(column)
308-
hook_attribute_type(column.name, super)
309-
end
310310
end
311311
end
312312
end

activerecord/lib/active_record/model_schema/schema.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize(model_class, context_key)
3232

3333
# Returns the columns hash for this schema context
3434
def columns_hash
35-
model_class.send(:load_schema) unless @columns_hash
35+
model_class.load_schema unless @columns_hash
3636
@columns_hash
3737
end
3838

@@ -62,11 +62,11 @@ def primary_key
6262
def _default_attributes
6363
@default_attributes ||= begin
6464
attributes_hash = columns_hash.transform_values do |column|
65-
ActiveModel::Attribute.from_database(column.name, column.default, model_class.send(:type_for_column, column))
65+
ActiveModel::Attribute.from_database(column.name, column.default, model_class.type_for_column(column))
6666
end
6767

6868
attribute_set = ActiveModel::AttributeSet.new(attributes_hash)
69-
model_class.send(:apply_pending_attribute_modifications, attribute_set)
69+
model_class.apply_pending_attribute_modifications(attribute_set)
7070
attribute_set
7171
end
7272
end
@@ -81,7 +81,7 @@ def attributes_builder
8181

8282
# Returns column defaults hash
8383
def column_defaults
84-
model_class.send(:load_schema)
84+
model_class.load_schema
8585
@column_defaults ||= _default_attributes.deep_dup.to_hash.freeze
8686
end
8787

0 commit comments

Comments
 (0)