instance method
define_proxy_call
Ruby on Rails 7.0.10
Since v5.2.8.1 PrivateSignature
define_proxy_call(code_generator, name, target, parameters, *call_args, namespace:)
Define a method name in mod that dispatches to send using the given extra args. This falls back on send if the called name cannot be compiled.
Parameters
-
code_generatorreq -
namereq -
targetreq -
parametersreq -
call_argsrest -
namespacekeyreq
Source
# File activemodel/lib/active_model/attribute_methods.rb, line 383
def define_proxy_call(code_generator, name, target, parameters, *call_args, namespace:)
mangled_name = name
unless NAME_COMPILABLE_REGEXP.match?(name)
mangled_name = "__temp__#{name.unpack1("h*")}"
end
code_generator.define_cached_method(name, as: mangled_name, namespace: :"#{namespace}_#{target}") do |batch|
call_args.map!(&:inspect)
call_args << parameters if parameters
body = if CALL_COMPILABLE_REGEXP.match?(target)
"self.#{target}(#{call_args.join(", ")})"
else
call_args.unshift(":'#{target}'")
"send(#{call_args.join(", ")})"
end
modifier = parameters == FORWARD_PARAMETERS ? "ruby2_keywords " : ""
batch <<
"#{modifier}def #{mangled_name}(#{parameters || ''})" <<
body <<
"end"
end
end
Defined in activemodel/lib/active_model/attribute_methods.rb line 383
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::AttributeMethods::ClassMethods