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(bind_values) ⇒ BindMap

Returns a new instance of BindMap.



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

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

  bind_values.each_with_index do |(_, value), i|
    if Substitute === value
      @indexes << i
    end
  end
end

Instance Method Details

#bind(values) ⇒ Object



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

def bind(values)
  bvs = @bind_values.map { |pair| pair.dup }
  @indexes.each_with_index { |offset,i| bvs[offset][1] = values[i] }
  bvs
end