@@ -231,21 +231,7 @@ def alias_attribute_method_definition(code_generator, pattern, new_name, old_nam
231
231
call_args = [ ]
232
232
call_args << parameters if parameters
233
233
234
- code_generator . define_cached_method ( method_name , as : mangled_name , namespace : :alias_attribute ) do |batch |
235
- body = if CALL_COMPILABLE_REGEXP . match? ( target_name )
236
- "self.#{ target_name } (#{ call_args . join ( ", " ) } )"
237
- else
238
- call_args . unshift ( ":'#{ target_name } '" )
239
- "send(#{ call_args . join ( ", " ) } )"
240
- end
241
-
242
- modifier = parameters == FORWARD_PARAMETERS ? "ruby2_keywords " : ""
243
-
244
- batch <<
245
- "#{ modifier } def #{ mangled_name } (#{ parameters || '' } )" <<
246
- body <<
247
- "end"
248
- end
234
+ define_call ( code_generator , method_name , target_name , mangled_name , parameters , call_args , namespace : :alias_attribute )
249
235
end
250
236
251
237
# Is +new_name+ an alias?
@@ -424,11 +410,25 @@ def define_proxy_call(code_generator, name, proxy_target, parameters, *call_args
424
410
call_args << parameters if parameters
425
411
namespace = :"#{ namespace } _#{ proxy_target } _#{ call_args . join ( "_" ) } }"
426
412
413
+ define_call ( code_generator , name , proxy_target , mangled_name , parameters , call_args , namespace : namespace )
414
+ end
415
+
416
+ def build_mangled_name ( name )
417
+ mangled_name = name
418
+
419
+ unless NAME_COMPILABLE_REGEXP . match? ( name )
420
+ mangled_name = "__temp__#{ name . unpack1 ( "h*" ) } "
421
+ end
422
+
423
+ mangled_name
424
+ end
425
+
426
+ def define_call ( code_generator , name , target_name , mangled_name , parameters , call_args , namespace :)
427
427
code_generator . define_cached_method ( name , as : mangled_name , namespace : namespace ) do |batch |
428
- body = if CALL_COMPILABLE_REGEXP . match? ( proxy_target )
429
- "self.#{ proxy_target } (#{ call_args . join ( ", " ) } )"
428
+ body = if CALL_COMPILABLE_REGEXP . match? ( target_name )
429
+ "self.#{ target_name } (#{ call_args . join ( ", " ) } )"
430
430
else
431
- call_args . unshift ( ":'#{ proxy_target } '" )
431
+ call_args . unshift ( ":'#{ target_name } '" )
432
432
"send(#{ call_args . join ( ", " ) } )"
433
433
end
434
434
@@ -441,16 +441,6 @@ def define_proxy_call(code_generator, name, proxy_target, parameters, *call_args
441
441
end
442
442
end
443
443
444
- def build_mangled_name ( name )
445
- mangled_name = name
446
-
447
- unless NAME_COMPILABLE_REGEXP . match? ( name )
448
- mangled_name = "__temp__#{ name . unpack1 ( "h*" ) } "
449
- end
450
-
451
- mangled_name
452
- end
453
-
454
444
class AttributeMethodPattern # :nodoc:
455
445
attr_reader :prefix , :suffix , :proxy_target , :parameters
456
446
0 commit comments