Class: Riddle::Query::Insert
- Inherits:
-
Object
- Object
- Riddle::Query::Insert
- Defined in:
- lib/riddle/query/insert.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(index, columns = [], values = []) ⇒ Insert
constructor
A new instance of Insert.
- #replace! ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(index, columns = [], values = []) ⇒ Insert
Returns a new instance of Insert.
6 7 8 9 10 11 |
# File 'lib/riddle/query/insert.rb', line 6 def initialize(index, columns = [], values = []) @index = index @columns = columns @values = values.first.is_a?(Array) ? values : [values] @replace = false end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
4 5 6 |
# File 'lib/riddle/query/insert.rb', line 4 def columns @columns end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
4 5 6 |
# File 'lib/riddle/query/insert.rb', line 4 def values @values end |
Instance Method Details
#replace! ⇒ Object
13 14 15 16 |
# File 'lib/riddle/query/insert.rb', line 13 def replace! @replace = true self end |
#to_sql ⇒ Object
18 19 20 |
# File 'lib/riddle/query/insert.rb', line 18 def to_sql "#{command} INTO #{@index} (#{columns_to_s}) VALUES (#{values_to_s})" end |