class YeSQL::Bindings::Extract
Attributes
hash[R]
index[R]
indexed_bindings[R]
value[R]
Public Class Methods
new(hash, indexed_bindings, index, value)
click to toggle source
# File lib/yesql/bindings/extract.rb, line 11 def initialize(hash, indexed_bindings, index, value) @hash = hash @index = index @indexed_bindings = indexed_bindings @value = value end
Public Instance Methods
bind_vals()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 18 def bind_vals return [nil, value] unless array? value.map { |bind| [nil, bind] } end
bind_vars()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 24 def bind_vars if mysql? return "?" unless array? Array.new(size, "?").join(", ") elsif pg? return "$#{last_val}" unless array? value.map.with_index(bind_index) { |_, i| "$#{i}" }.join(", ") end end
last_val()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 36 def last_val prev_last_val + current_val_size end
prev()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 40 def prev return if first? indexed_bindings[index - 2].first end
Private Instance Methods
array?()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 66 def array? value.is_a?(Array) end
bind_index()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 70 def bind_index return 1 if first? prev_last_val + 1 end
current_val_size()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 50 def current_val_size return size if array? 1 end
first?()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 62 def first? index == 1 end
prev_last_val()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 56 def prev_last_val return 0 if first? hash[prev][:last_val] end
size()
click to toggle source
# File lib/yesql/bindings/extract.rb, line 76 def size value.size end