class Perpetuity::Postgres::SQLUpdate
Attributes
attributes[R]
id[R]
klass[R]
Public Class Methods
new(klass, id, attributes)
click to toggle source
# File lib/perpetuity/postgres/sql_update.rb, line 9 def initialize klass, id, attributes @class = klass @id = id @attributes = attributes end
Public Instance Methods
to_s()
click to toggle source
# File lib/perpetuity/postgres/sql_update.rb, line 15 def to_s sql = "UPDATE #{TableName.new(@class)}" if attributes.any? sql << " SET " sql << attributes.map do |name, value| value = SQLValue.new(value) if attributes.is_a? Hash "#{name} = #{value}" end.join(',') end sql << " WHERE id = #{SQLValue.new(id)}" end