Class: Sqlbuilder::Statements::Update

Inherits:
Object
  • Object
show all
Includes:
Builders::UpdateBuilder
Defined in:
lib/sqlbuilder/statements/update.rb

Instance Method Summary collapse

Methods included from Builders::UpdateBuilder

#build_set, #build_where

Constructor Details

#initialize(utils) ⇒ Update

Returns a new instance of Update.



8
9
10
# File 'lib/sqlbuilder/statements/update.rb', line 8

def initialize(utils)
  @utils = utils
end

Instance Method Details

#buildObject



30
31
32
33
34
35
36
37
# File 'lib/sqlbuilder/statements/update.rb', line 30

def build
  sql = "UPDATE #{@table}"

  sql << " #{build_set}"
  sql << " #{build_where}" if @where

  sql
end

#set(set) ⇒ Object



18
19
20
21
22
# File 'lib/sqlbuilder/statements/update.rb', line 18

def set(set)
  @set = set

  self
end

#table(table) ⇒ Object



12
13
14
15
16
# File 'lib/sqlbuilder/statements/update.rb', line 12

def table(table)
  @table = table

  self
end

#where(filter_hash) ⇒ Object



24
25
26
27
28
# File 'lib/sqlbuilder/statements/update.rb', line 24

def where(filter_hash)
  @where = filter_hash

  self
end