Define a method `name` in `mod` that dispatches to `send` using the given
`extra` args. This fallbacks `define_method` and `send` if the given names
cannot be compiled.
# File activemodel/lib/active_model/attribute_methods.rb, line 328
def define_optimized_call(mod, name, send, *extra) #:nodoc:
if name =~ NAME_COMPILABLE_REGEXP
defn = "def #{name}(*args)"
else
defn = "define_method(:'#{name}') do |*args|"
end
extra = (extra.map(&:inspect) << "*args").join(", ")
if send =~ CALL_COMPILABLE_REGEXP
target = "#{send}(#{extra})"
else
target = "send(:'#{send}', #{extra})"
end
mod.module_eval #{defn} #{target} end, __FILE__, __LINE__ + 1
end