Class: ActiveRecord::StatementCache::PartialQueryCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/statement_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePartialQueryCollector

Returns a new instance of PartialQueryCollector.



67
68
69
70
# File 'lib/active_record/statement_cache.rb', line 67

def initialize
  @parts = []
  @binds = []
end

Instance Attribute Details

#preparableObject

Returns the value of attribute preparable.



65
66
67
# File 'lib/active_record/statement_cache.rb', line 65

def preparable
  @preparable
end

Instance Method Details

#<<(str) ⇒ Object



72
73
74
75
# File 'lib/active_record/statement_cache.rb', line 72

def <<(str)
  @parts << str
  self
end

#add_bind(obj) ⇒ Object



77
78
79
80
81
# File 'lib/active_record/statement_cache.rb', line 77

def add_bind(obj)
  @binds << obj
  @parts << Substitute.new
  self
end

#add_binds(binds, proc_for_binds = nil) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/active_record/statement_cache.rb', line 83

def add_binds(binds, proc_for_binds = nil)
  @binds.concat proc_for_binds ? binds.map(&proc_for_binds) : binds
  binds.size.times do |i|
    @parts << ", " unless i == 0
    @parts << Substitute.new
  end
  self
end

#valueObject



92
93
94
# File 'lib/active_record/statement_cache.rb', line 92

def value
  [@parts, @binds]
end