Module: ActiveRecord::Delegation

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

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods, ClassSpecificRelation

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



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

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)


105
106
107
108
109
# File 'lib/active_record/relation/delegation.rb', line 105

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