Sha256: 4c9be1ef609e7ce8bdb52dfd1cfe5205a52eefa2a1d3e5362db96a9fb8325ef9
Contents?: true
Size: 729 Bytes
Versions: 5
Compression:
Stored size: 729 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 = self.class.connection.raw_connection con.exec(sql, id).fetch.first end end end
Version data entries
5 entries across 5 versions & 1 rubygems