@@ -225,11 +225,8 @@ def alias_attribute_method_definition(code_generator, pattern, new_name, old_nam
225
225
method_name = pattern . method_name ( new_name ) . to_s
226
226
target_name = pattern . method_name ( old_name ) . to_s
227
227
parameters = pattern . parameters
228
- mangled_name = target_name
229
228
230
- unless NAME_COMPILABLE_REGEXP . match? ( target_name )
231
- mangled_name = "__temp__#{ target_name . unpack1 ( "h*" ) } "
232
- end
229
+ mangled_name = build_mangled_name ( target_name )
233
230
234
231
code_generator . define_cached_method ( method_name , as : mangled_name , namespace : :alias_attribute ) do |batch |
235
232
body = if CALL_COMPILABLE_REGEXP . match? ( target_name )
@@ -419,10 +416,7 @@ def attribute_method_patterns_matching(method_name)
419
416
# using the given `extra` args. This falls back on `send`
420
417
# if the called name cannot be compiled.
421
418
def define_proxy_call ( code_generator , name , proxy_target , parameters , *call_args , namespace :)
422
- mangled_name = name
423
- unless NAME_COMPILABLE_REGEXP . match? ( name )
424
- mangled_name = "__temp__#{ name . unpack1 ( "h*" ) } "
425
- end
419
+ mangled_name = build_mangled_name ( name )
426
420
427
421
call_args . map! ( &:inspect )
428
422
call_args << parameters if parameters
@@ -445,6 +439,16 @@ def define_proxy_call(code_generator, name, proxy_target, parameters, *call_args
445
439
end
446
440
end
447
441
442
+ def build_mangled_name ( name )
443
+ mangled_name = name
444
+
445
+ unless NAME_COMPILABLE_REGEXP . match? ( name )
446
+ mangled_name = "__temp__#{ name . unpack1 ( "h*" ) } "
447
+ end
448
+
449
+ mangled_name
450
+ end
451
+
448
452
class AttributeMethodPattern # :nodoc:
449
453
attr_reader :prefix , :suffix , :proxy_target , :parameters
450
454
0 commit comments