Class: MassInsert::Builder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mass_insert/builder/base.rb

Instance Method Summary collapse

Instance Method Details

#adapter_classObject

Returns the class of the correct database adapter according to the database engine that is used in Rails project.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mass_insert/builder/base.rb', line 13

def adapter_class
  case Utilities.adapter
  when "mysql2"
    Adapters::Mysql2Adapter
  when "postgresql"
    Adapters::PostgreSQLAdapter
  when "sqlite3"
    Adapters::SQLite3Adapter
  when "sqlserver"
    Adapters::SQLServerAdapter
  end
end

#build(values, options) ⇒ Object

This function gets the correct adapter class and returns the sql string ready to be executed.



7
8
9
# File 'lib/mass_insert/builder/base.rb', line 7

def build values, options
  adapter_class.new(values, options).execute
end