Sha256: 069dc831ba79424802a06b9480f1e49c5d0da15f0e1b7d95879507f254764af0
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
module MassInsert class QueryBuilder attr_accessor :values, :options def initialize values, options @values = values @options = options end # This function calls the correct adapter class and returns the # sql string ready to be executed and returns it to be execute in # the QueryExecution class. def build adapter_instance_class.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 an instance of the correct database adapter and this # instance will be called to generate the sql string. The values # and options are passed by params when the correct adapter class # is instanced. def adapter_instance_class case adapter when "mysql2" Adapters::Mysql2Adapter.new(values, options) when "postgresql" Adapters::PostgreSQLAdapter.new(values, options) when "sqlite3" Adapters::SQLite3Adapter.new(values, options) when "sqlserver" Adapters::SQLServerAdapter.new(values, options) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mass_insert-0.0.2 | lib/mass_insert/query_builder.rb |
mass_insert-0.0.1 | lib/mass_insert/query_builder.rb |