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

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

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#delegate(method, opts = {}) ⇒ Object



81
82
83
84
85
86
# File 'lib/active_record/relation/delegation.rb', line 81

def delegate(method, opts = {})
  @delegation_mutex.synchronize do
    return if method_defined?(method)
    super
  end
end

#delegate_to_scoped_klass(method) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/active_record/relation/delegation.rb', line 63

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

    if method.to_s =~ /\A[a-zA-Z_]\w*[!?]?\z/
      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



59
60
61
# File 'lib/active_record/relation/delegation.rb', line 59

def name
  superclass.name
end