Sha256: 3a600ca48103765d7549ce91d3a719ec6e61600deb8e118c5531e67ce71e759d

Contents?: true

Size: 739 Bytes

Versions: 27

Compression:

Stored size: 739 Bytes

Contents

module RailsConnector

  module BlobOracle
    def self.included(base)
      base.instance_eval do
        define_method :store_data do
          store_data_atomically {|f| fetch_into_file(f)}
        end
      end
    end

    def fetch_into_file(file)
      blob = blob_handle
      while data = blob.read(buff_size ||= 1.megabyte)
        file <<  data
        data = nil
        GC.start
      end
    ensure
      blob.close if blob
    end

    private

    def sql
      %{
        SELECT blob_data
        FROM #{self.class.table_name}
        WHERE #{self.class.primary_key} = :1
      }
    end

    def blob_handle
      con = connection.instance_variable_get '@connection'
      con.exec(sql, id).fetch.first
    end
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
infopark_fiona_connector-6.8.0.480.261594408 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.444.171626367 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.406.131718077 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.356.19698103 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.348.160665197 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.328.4a753fc lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.322.c003f11 lib/rails_connector/blob_oracle.rb