class YeSQL::Bindings::Extractor

Attributes

bindings[R]
indexed_bindings[R]

Public Class Methods

new(bindings: {}) click to toggle source
# File lib/yesql/bindings/extractor.rb, line 8
def initialize(bindings: {})
  @bindings = bindings
  @indexed_bindings = bindings.to_a
end

Public Instance Methods

call() click to toggle source
# File lib/yesql/bindings/extractor.rb, line 13
def call
  bindings
    .each_with_object({})
    .with_index(1) do |((key, value), hash), index|
      hash[key] = binding_extracts(hash, indexed_bindings, index, key, value)
    end
end

Private Instance Methods

binding_extracts(hash, indexed_bindings, index, key, value) click to toggle source
# File lib/yesql/bindings/extractor.rb, line 25
def binding_extracts(hash, indexed_bindings, index, key, value)
  ::YeSQL::Bindings::Extract.new(hash, indexed_bindings, index, value).tap do |extract|
    break {
      bind: {
        vals: extract.bind_vals,
        vars: extract.bind_vars
      },
      last_val: extract.last_val,
      match: key,
      prev: extract.prev,
      value: value
    }
  end
end