Class: ActiveRecord::StatementCache::PartialQuery
- Inherits:
-
Object
- Object
- ActiveRecord::StatementCache::PartialQuery
- Defined in:
- ext/active_record/statement_cache.rb
Instance Method Summary collapse
-
#initialize(values, sunstone = false) ⇒ PartialQuery
constructor
A new instance of PartialQuery.
- #sql_for(binds, connection) ⇒ Object
Constructor Details
#initialize(values, sunstone = false) ⇒ PartialQuery
Returns a new instance of PartialQuery.
5 6 7 8 9 10 11 12 13 |
# File 'ext/active_record/statement_cache.rb', line 5 def initialize(values, sunstone=false) @values = values @indexes = if sunstone else values.each_with_index.find_all { |thing, i| Substitute === thing }.map(&:last) end end |
Instance Method Details
#sql_for(binds, connection) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'ext/active_record/statement_cache.rb', line 15 def sql_for(binds, connection) if connection.is_a?(ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter) @values else val = @values.dup @indexes.each do |i| value = binds.shift if ActiveModel::Attribute === value value = value.value_for_database end val[i] = connection.quote(value) end val.join end end |