Class: Sequel::Postgres::AutoParameterize::StringWithArray
- Defined in:
- lib/sequel/extensions/pg_auto_parameterize.rb
Overview
String that holds an array of parameters
Constant Summary collapse
- PLACEHOLDER =
'$'.freeze
- CAST =
'::'.freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
The array of parameters used by this query.
Instance Method Summary collapse
-
#add_arg(s, type = nil) ⇒ 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.
-
#inspect ⇒ Object
Show args when the string is inspected.
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
Instance Attribute Details
#args ⇒ Object (readonly)
The array of parameters used by this query.
73 74 75 |
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 73 def args @args end |
Instance Method Details
#add_arg(s, type = nil) ⇒ 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.
78 79 80 81 82 83 |
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 78 def add_arg(s, type=nil) @args ||= [] @args << s self << PLACEHOLDER << @args.length.to_s self << CAST << type.to_s if type end |
#inspect ⇒ Object
Show args when the string is inspected
86 87 88 |
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 86 def inspect @args ? "#{self}; #{@args.inspect}".inspect : super end |