Sha256: a6eac5da2bb40c2515a2ea56ef4f49b4cfb755fd241e7adecb6bfcbd64a3b25c

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 Bytes

Contents

module Itiel
  module Script
    #
    # Executes a SQL script or command on the specified
    # connection
    #
    class SQLScript
      include ChainedStep
      include Itiel::DB::SQLConnectable

      attr_accessor :sql

      def initialize(sql=nil, &block)
        if block_given?
          self.sql = block
        else
          self.sql = sql
        end
      end

      def execute(input_stream=nil)
        db = self.class.sequel_connection(connection)
        if sql.respond_to?(:call)
          input_stream.each do |row|
            db << sql.call(row)
          end
        else
          db << sql
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itiel-0.1.2 lib/itiel/script/sql_script.rb