Module: ActiveRecord::Delegation

Extended by:
ActiveSupport::Concern
Included in:
Relation
Defined in:
activerecord/lib/active_record/relation/delegation.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods, ClassSpecificRelation

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

append_features, extended, included

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (protected)


111
112
113
114
115
116
117
118
119
120
121
# File 'activerecord/lib/active_record/relation/delegation.rb', line 111

def method_missing(method, *args, &block)
  if @klass.respond_to?(method)
    scoping { @klass.send(method, *args, &block) }
  elsif Array.method_defined?(method)
    to_a.send(method, *args, &block)
  elsif arel.respond_to?(method)
    arel.send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

103
104
105
106
107
# File 'activerecord/lib/active_record/relation/delegation.rb', line 103

def respond_to?(method, include_private = false)
  super || Array.method_defined?(method) ||
    @klass.respond_to?(method, include_private) ||
    arel.respond_to?(method, include_private)
end