Class: InsertInto::Statement
- Inherits:
-
Object
- Object
- InsertInto::Statement
- Defined in:
- lib/insert_into/statement.rb
Instance Attribute Summary collapse
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
-
#initialize(table_name) ⇒ Statement
constructor
A new instance of Statement.
- #new_row {|row| ... } ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(table_name) ⇒ Statement
Returns a new instance of Statement.
5 6 7 8 |
# File 'lib/insert_into/statement.rb', line 5 def initialize(table_name) @table_name = table_name @rows = [] end |
Instance Attribute Details
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
3 4 5 |
# File 'lib/insert_into/statement.rb', line 3 def table_name @table_name end |
Instance Method Details
#new_row {|row| ... } ⇒ Object
10 11 12 13 14 |
# File 'lib/insert_into/statement.rb', line 10 def new_row row = Row.new yield row @rows << row end |
#to_sql ⇒ Object
16 17 18 |
# File 'lib/insert_into/statement.rb', line 16 def to_sql "INSERT INTO #{table_name} (#{column_names.join(',')}) VALUES #{values_string};" end |