Class: Sequel::SQL::PlaceholderLiteralString

Inherits:
Expression show all
Defined in:
lib/sequel/sql.rb

Overview

Represents a literal string with placeholders and arguments. This is necessary to ensure delayed literalization of the arguments required for the prepared statement support

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

attr_reader, comparison_attrs, #eql?, #lit, #sql_literal

Constructor Details

#initialize(str, args, parens = false) ⇒ PlaceholderLiteralString

Create an object with the given string, placeholder arguments, and parens flag.



734
735
736
737
738
# File 'lib/sequel/sql.rb', line 734

def initialize(str, args, parens=false)
  @str = str
  @args = args.is_a?(Array) && args.length == 1 && (v = args.at(0)).is_a?(Hash) ? v : args
  @parens = parens
end

Instance Attribute Details

#argsObject (readonly)

The arguments that will be subsituted into the placeholders. Either an array of unnamed placeholders (which will be substituted in order for ? characters), or a hash of named placeholders (which will be substituted for :key phrases).



725
726
727
# File 'lib/sequel/sql.rb', line 725

def args
  @args
end

#parensObject (readonly)

Whether to surround the expression with parantheses



731
732
733
# File 'lib/sequel/sql.rb', line 731

def parens
  @parens
end

#strObject (readonly)

The literal string containing placeholders



728
729
730
# File 'lib/sequel/sql.rb', line 728

def str
  @str
end