class YeSQL::Errors::NoBindingsProvidedError

Attributes

binds[R]
file_path[R]

Public Class Methods

new(binds, file_path) click to toggle source
# File lib/yesql/errors/no_bindings_provided_error.rb, line 10
def initialize(binds, file_path)
  @binds = binds
  @file_path = file_path
end

Public Instance Methods

validate_statement_bindings() click to toggle source
# File lib/yesql/errors/no_bindings_provided_error.rb, line 15
def validate_statement_bindings
  return if statement_binds.size.zero?
  return if expected_binds?

  raise ::ArgumentError, message
end

Private Instance Methods

expected_binds?() click to toggle source
# File lib/yesql/errors/no_bindings_provided_error.rb, line 44
def expected_binds?
  binds.is_a?(::Hash) && !binds.empty?
end
message() click to toggle source
# File lib/yesql/errors/no_bindings_provided_error.rb, line 26
      def message
"\nYeSQL invoked without bindings.

Expected bindings are:

#{renderable_statement_binds}\n"
      end
renderable_statement_binds() click to toggle source
# File lib/yesql/errors/no_bindings_provided_error.rb, line 40
def renderable_statement_binds
  statement_binds.flatten.map { |bind| "- `#{bind}`\n" }.join
end
statement_binds() click to toggle source
# File lib/yesql/errors/no_bindings_provided_error.rb, line 34
def statement_binds
  statement
    .scan(::YeSQL::BIND_REGEX)
    .tap { |scanned_binds| break (scanned_binds || []).sort }
end