Sha256: bcb2c26282b2cc1f248cf454ddff2bf099d72d7a8b898b8d4c7ef4a4fd12e934

Contents?: true

Size: 748 Bytes

Versions: 6

Compression:

Stored size: 748 Bytes

Contents

module RailsConnector

  module BlobOracle #:nodoc:
    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

6 entries across 6 versions & 1 rubygems

Version Path
infopark_fiona_connector-6.8.0.210.ed204b0 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.110.6570b45 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.72.d18d096 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.23.da7f96b lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.16.def5e85 lib/rails_connector/blob_oracle.rb
infopark_fiona_connector-6.8.0.beta.200.891.647580e lib/rails_connector/blob_oracle.rb