Sha256: f4605cfb9db8058ac3c569aeb8489f9fffe4121dc46d01e414d5acb8975f67ce
Contents?: true
Size: 1020 Bytes
Versions: 3
Compression:
Stored size: 1020 Bytes
Contents
class Upsert # @private module Quoter ISO8601_DATE = '%F' def quote_value(v) case v when NilClass 'NULL' when Upsert::Binary quote_binary v # must be defined by base when String quote_string v # must be defined by base when TrueClass, FalseClass quote_boolean v when BigDecimal quote_big_decimal v when Numeric v when Symbol quote_string v.to_s when Time, DateTime quote_time v # must be defined by base when Date quote_string v.strftime(ISO8601_DATE) else raise "not sure how to quote #{v.class}: #{v.inspect}" end end def quote_idents(idents) idents.map { |k| quote_ident(k) }.join(',') # must be defined by base end def quote_values(values) values.map { |v| quote_value(v) }.join(',') end def quote_pairs(pairs) pairs.map { |k, v| [quote_ident(k),quote_value(v)].join('=') }.join(',') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
upsert-0.1.2 | lib/upsert/quoter.rb |
upsert-0.1.1 | lib/upsert/quoter.rb |
upsert-0.1.0 | lib/upsert/quoter.rb |