Class: SQL::Composer::Statement

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sql/composer/statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Statement

Returns a new instance of Statement.



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

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#compilerObject



32
33
34
# File 'lib/sql/composer/statement.rb', line 32

def compiler
  options.fetch(:compiler)
end

#each(&block) ⇒ Object



14
15
16
# File 'lib/sql/composer/statement.rb', line 14

def each(&block)
  nodes.each(&block)
end

#nodesObject



36
37
38
# File 'lib/sql/composer/statement.rb', line 36

def nodes
  compiler.nodes
end

#set(values) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/sql/composer/statement.rb', line 18

def set(values)
  tokens = compiler.tokens.new

  values.each do |key, value|
    tokens.set(key, value)
  end

  compiler.with(tokens: tokens)
end

#to_sObject



28
29
30
# File 'lib/sql/composer/statement.rb', line 28

def to_s
  compiler.to_s
end