Sha256: 6cd63595e2ece73eb1e8b4625fa7fbcd755515074c8ba6211ce58f171855895d

Contents?: true

Size: 731 Bytes

Versions: 3

Compression:

Stored size: 731 Bytes

Contents

module Itiel
  module Load
    #
    # Loads the stream into a database table.
    #
    # Usage:
    #
    #     @loader = Itiel::Load::DatabaseTable.new :connection, "table_name"
    #
    class DatabaseTable
      include ChainedStep
      include Itiel::Nameable
      include Itiel::DB::SQLConnectable

      attr_accessor :table_name

      def initialize(connection, table_name)
        self.connection = connection
        self.table_name = table_name
      end

      def persist(input_stream)
        input_stream.each do |element|
          table.insert(element)
        end
      end

      def table
        @@db ||= self.class.sequel_connection(connection)
        @@db[table_name.to_sym]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
itiel-0.1.2 lib/itiel/load/database_table.rb
itiel-0.1.1 lib/itiel/load/database_table.rb
itiel-0.1.0 lib/itiel/load/database_table.rb