Class: ActiveRecord::Futures::QueryRecording::KlassProxy

Inherits:
Proxy
  • Object
show all
Defined in:
lib/active_record/futures/query_recording.rb

Instance Attribute Summary collapse

Attributes inherited from Proxy

#proxied

Instance Method Summary collapse

Methods inherited from Proxy

#!=, #==, #method_missing, #proxy?, #respond_to?

Constructor Details

#initialize(klass, connection) ⇒ KlassProxy

Returns a new instance of KlassProxy.



20
21
22
23
24
# File 'lib/active_record/futures/query_recording.rb', line 20

def initialize(klass, connection)
  super(klass)
  @klass = klass
  @connection = connection
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveRecord::Futures::Proxy

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



18
19
20
# File 'lib/active_record/futures/query_recording.rb', line 18

def connection
  @connection
end

#klassObject (readonly)

Returns the value of attribute klass.



18
19
20
# File 'lib/active_record/futures/query_recording.rb', line 18

def klass
  @klass
end

Instance Method Details

#build_default_scopeObject



26
27
28
29
30
# File 'lib/active_record/futures/query_recording.rb', line 26

def build_default_scope
  scope = @klass.send(:build_default_scope)
  scope.instance_variable_set(:@klass, self)
  scope
end

#find_by_sql(sql, binds = []) ⇒ Object



32
33
34
35
36
# File 'lib/active_record/futures/query_recording.rb', line 32

def find_by_sql(sql, binds = [])
  connection.recorded_query = sanitize_sql(sql)
  connection.recorded_binds = binds
  []
end