Class: InsertSelect::Adapters::BaseAdapter
- Inherits:
-
Object
- Object
- InsertSelect::Adapters::BaseAdapter
- Defined in:
- lib/insert_select/adapters/base_adapter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #build_sql(builder) ⇒ Object
-
#initialize(table_name, connection) ⇒ BaseAdapter
constructor
A new instance of BaseAdapter.
Constructor Details
#initialize(table_name, connection) ⇒ BaseAdapter
Returns a new instance of BaseAdapter.
7 8 9 10 |
# File 'lib/insert_select/adapters/base_adapter.rb', line 7 def initialize(table_name, connection) @table_name = table_name @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/insert_select/adapters/base_adapter.rb', line 6 def connection @connection end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
6 7 8 |
# File 'lib/insert_select/adapters/base_adapter.rb', line 6 def table_name @table_name end |
Instance Method Details
#build_sql(builder) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/insert_select/adapters/base_adapter.rb', line 12 def build_sql(builder) into = builder.into if into.present? builder.reselect_relation! stmt = "INSERT #{into}" stmt += " #{builder.relation_sql}" else quoted_table_name = @connection.quote_table_name(table_name) stmt = "INSERT INTO #{quoted_table_name} #{builder.relation_sql}" end stmt end |