instance method define_proxy_call

Ruby on Rails 6.0.6

Since v5.2.8.1 Private

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

define_proxy_call(include_private, mod, name, target, *extra)

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.

Parameters

include_private req
mod req
name req
target req
extra rest
Source
# File activemodel/lib/active_model/attribute_methods.rb, line 366
        def define_proxy_call(include_private, mod, 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

          mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1
            #{defn}
              #{body}
            end
            ruby2_keywords(:'#{name}') if respond_to?(:ruby2_keywords, true)
          RUBY
        end

Defined in activemodel/lib/active_model/attribute_methods.rb line 366 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveModel::AttributeMethods::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close