Class: ActiveRecord::StatementCache::BindMap

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(bound_attributes) ⇒ BindMap

Returns a new instance of BindMap.



72
73
74
75
76
77
78
79
80
81
# File 'lib/active_record/statement_cache.rb', line 72

def initialize(bound_attributes)
  @indexes = []
  @bound_attributes = bound_attributes

  bound_attributes.each_with_index do |attr, i|
    if Substitute === attr.value
      @indexes << i
    end
  end
end

Instance Method Details

#bind(values) ⇒ Object



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

def bind(values)
  bas = @bound_attributes.dup
  @indexes.each_with_index { |offset, i| bas[offset] = bas[offset].with_cast_value(values[i]) }
  bas
end