Define a method `name` in `mod` that dispatches to `send` using the given
`extra` args. This falls back on `define_method` and `send` if the given
names cannot be compiled.
# File activemodel/lib/active_model/attribute_methods.rb, line 408
def define_proxy_call(include_private, code_generator, name, target, *extra)
defn = if NAME_COMPILABLE_REGEXP.match?(name)
"def #{name}(*args)"
else
"define_method(:'#{name}') do |*args|"
end
extra = (extra.map!(&:inspect) << "*args").join(", ")
body = if CALL_COMPILABLE_REGEXP.match?(target)
"#{"self." unless include_private}#{target}(#{extra})"
else
"send(:'#{target}', #{extra})"
end
code_generator <<
defn <<
body <<
"end" <<
"ruby2_keywords(:'#{name}') if respond_to?(:ruby2_keywords, true)"
end