Class: Object

Inherits:
BasicObject
Defined in:
lib/sql/statement.rb

Overview

Everything in Ruby is a descendant of the Object class. Practically speaking, this means that any object that hasn’t otherwise defined the placeheld and to_sqlpart methods will be treated as a piece of data (rather than as an SQL instruction).

Instance Method Summary collapse

Instance Method Details

#placeheldObject

When the string representation includes unbound variables (represented in sql with a ?), then the values to be bound to them are returned here, in the proper order. This allows SQL statements to be called in a manner similar to

s=Select.new
s << Select.new {...}
dbh.execute(s.to_s, *s.placeheld)

When there are no unbound variables, and empty array is returned.



19
# File 'lib/sql/statement.rb', line 19

def placeheld; [self]; end

#to_sqlpartObject

Generates a string representation to be included in the SQL statement’s string representation.



9
10
11
# File 'lib/sql/statement.rb', line 9

def to_sqlpart
   "?"
end