Sha256: 4865c285e82da6b54135dace0ad5e923d079a2a4ba4c12a0e44566f3410ac434

Contents?: true

Size: 446 Bytes

Versions: 2

Compression:

Stored size: 446 Bytes

Contents

module Metacrunch
  class Db::Writer

    def initialize(database_connection_or_url, dataset_proc, options = {})
      @db = if database_connection_or_url.is_a?(String)
        Sequel.connect(database_connection_or_url, options)
      else
        database_connection_or_url
      end

      @dataset = dataset_proc.call(@db)
    end

    def write(data)
      @dataset.insert(data)
    end

    def close
      @db.disconnect
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metacrunch-3.0.1 lib/metacrunch/db/writer.rb
metacrunch-3.0.0 lib/metacrunch/db/writer.rb