Class: SQLKnit::Needle

Inherits:
Object
  • Object
show all
Defined in:
lib/needle.rb

Instance Method Summary collapse

Constructor Details

#initializeNeedle

Returns a new instance of Needle.



5
6
7
8
# File 'lib/needle.rb', line 5

def initialize
  @sql_select = SQL::Select.new
  @sql_from   = SQL::From.new
end

Instance Method Details

#from(*table_names, &block) ⇒ Object



14
15
16
17
# File 'lib/needle.rb', line 14

def from *table_names, &block
  table_names[0..-2].each {|table_name| @sql_from.add_table table_name }
  @sql_from.contextlize table_names.last, &block
end

#from_statementObject



23
24
25
# File 'lib/needle.rb', line 23

def from_statement
  @sql_from.to_statement
end

#select(&block) ⇒ Object



10
11
12
# File 'lib/needle.rb', line 10

def select &block
  @sql_select.instance_eval &block
end

#select_statementObject



19
20
21
# File 'lib/needle.rb', line 19

def select_statement
  @sql_select.to_statement
end