Module: ActiveRecord::Delegation::ClassSpecificRelation::ClassMethods

Defined in:
lib/active_record/relation/delegation.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#delegate_to_scoped_klass(method) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/active_record/relation/delegation.rb', line 90

def delegate_to_scoped_klass(method)
  @delegation_mutex.synchronize do
    return if method_defined?(method)

    if /\A[a-zA-Z_]\w*[!?]?\z/.match?(method)
      module_eval <<-RUBY, __FILE__, __LINE__ + 1
        def #{method}(*args, &block)
          scoping { @klass.#{method}(*args, &block) }
        end
      RUBY
    else
      define_method method do |*args, &block|
        scoping { @klass.public_send(method, *args, &block) }
      end
    end
  end
end

#nameObject



86
87
88
# File 'lib/active_record/relation/delegation.rb', line 86

def name
  superclass.name
end