Skip to content

Commit 8ec3843

Browse files
committed
Make duplication explicit between alias_attribute_method_definition and define_proxy_call
1 parent 01492e3 commit 8ec3843

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

activemodel/lib/active_model/attribute_methods.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,14 @@ def alias_attribute_method_definition(code_generator, pattern, new_name, old_nam
228228

229229
mangled_name = build_mangled_name(target_name)
230230

231+
call_args = []
232+
call_args << parameters if parameters
233+
231234
code_generator.define_cached_method(method_name, as: mangled_name, namespace: :alias_attribute) do |batch|
232235
body = if CALL_COMPILABLE_REGEXP.match?(target_name)
233-
"self.#{target_name}(#{parameters || ''})"
236+
"self.#{target_name}(#{call_args.join(", ")})"
234237
else
235-
call_args = [":'#{target_name}'"]
236-
call_args << parameters if parameters
238+
call_args.unshift(":'#{target_name}'")
237239
"send(#{call_args.join(", ")})"
238240
end
239241

0 commit comments

Comments
 (0)