Sha256: 404c87e4c6619dc410153be7dcd2bdcf799ef40362efb22c4058449423108470
Contents?: true
Size: 997 Bytes
Versions: 2
Compression:
Stored size: 997 Bytes
Contents
module MassInsert class QueryBuilder attr_accessor :values, :options def initialize values, options @values = values @options = options end # This function gets the correct adapter class and returns the # sql string ready to be executed. def build adapter_class.new(values, options).execute end # Returns a string that contains the adapter type previosly # configured in Rails project usually in the database.yml file. def adapter ActiveRecord::Base.connection.instance_values["config"][:adapter] end # Returns the class of the correct database adapter according to the # database engine that is used in Rails project. def adapter_class case adapter when "mysql2" Adapters::Mysql2Adapter when "postgresql" Adapters::PostgreSQLAdapter when "sqlite3" Adapters::SQLite3Adapter when "sqlserver" Adapters::SQLServerAdapter end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mass_insert-0.1.1 | lib/mass_insert/query_builder.rb |
mass_insert-0.1.0 | lib/mass_insert/query_builder.rb |