Class: ActiveRecord::StatementCache::PartialQueryCollector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePartialQueryCollector

Returns a new instance of PartialQueryCollector.



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

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

Instance Attribute Details

#preparableObject

Returns the value of attribute preparable.



69
70
71
# File 'activerecord/lib/active_record/statement_cache.rb', line 69

def preparable
  @preparable
end

#retryableObject

Returns the value of attribute retryable.



69
70
71
# File 'activerecord/lib/active_record/statement_cache.rb', line 69

def retryable
  @retryable
end

Instance Method Details

#<<(str) ⇒ Object



76
77
78
79
# File 'activerecord/lib/active_record/statement_cache.rb', line 76

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

#add_bind(obj) ⇒ Object



81
82
83
84
85
# File 'activerecord/lib/active_record/statement_cache.rb', line 81

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

#add_binds(binds, proc_for_binds = nil) ⇒ Object



87
88
89
90
91
92
93
94
# File 'activerecord/lib/active_record/statement_cache.rb', line 87

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



96
97
98
# File 'activerecord/lib/active_record/statement_cache.rb', line 96

def value
  [@parts, @binds]
end