Class: Sequel::Postgres::AutoParameterize::StringWithArray

Inherits:
String
  • Object
show all
Defined in:
lib/sequel/extensions/pg_auto_parameterize.rb

Overview

String that holds an array of parameters

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from String

#blank?, #camelize, #classify, #constantize, #dasherize, #demodulize, #foreign_key, #humanize, inflections, #lit, #pluralize, #singularize, #tableize, #titleize, #to_date, #to_datetime, #to_sequel_blob, #to_sequel_time, #to_time, #underscore

Methods included from SQL::CastMethods

#cast, #cast_numeric, #cast_string

Methods included from SQL::AliasMethods

#as

Instance Attribute Details

#argsObject (readonly)

The array of parameters used by this query.



70
71
72
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 70

def args
  @args
end

Instance Method Details

#add_arg(s, type) ⇒ Object

Add a new parameter to this query, which adds the parameter to the array of parameters, and an SQL placeholder to the query itself.



75
76
77
78
79
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 75

def add_arg(s, type)
  @args ||= []
  @args << s
  self << "$#{@args.length}::#{type}"
end

#inspectObject

Show args when the string is inspected



82
83
84
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 82

def inspect
  @args ? "#{self}; #{@args.inspect}".inspect : super
end