Sha256: 97016f2bbb62ae8c5d692464e22eceeb197312d1c2ac2d7af66ff6ce3d66f451

Contents?: true

Size: 596 Bytes

Versions: 9

Compression:

Stored size: 596 Bytes

Contents

module MassInsert
  class Process
    attr_reader :values, :options

    def initialize(values, options)
      @values  = values
      @options = options
    end

    def start
      ActiveRecord::Base.transaction do
        values.each_slice(per_batch).each do |batch|
          query = builder.build(batch, options)
          executer.execute(query)
        end
      end
    end

    private

    def builder
      @builder ||= Builder.new
    end

    def executer
      @executer ||= Executer.new
    end

    def per_batch
      options[:per_batch] || Utilities.per_batch
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mass_insert-1.0.0 lib/mass_insert/process.rb
mass_insert-0.2.7 lib/mass_insert/process.rb
mass_insert-0.2.6 lib/mass_insert/process.rb
mass_insert-0.2.5 lib/mass_insert/process.rb
mass_insert-0.2.4 lib/mass_insert/process.rb
mass_insert-0.2.3 lib/mass_insert/process.rb
mass_insert-0.2.2 lib/mass_insert/process.rb
mass_insert-0.2.1 lib/mass_insert/process.rb
mass_insert-0.2.0 lib/mass_insert/process.rb