Class: CarrierWave::Storage::PostgresqlLo::File

Inherits:
Object
  • Object
show all
Includes:
Adapters::JDBCConnection, Adapters::PGConnection
Defined in:
lib/carrierwave/storage/postgresql_lo.rb

Instance Method Summary collapse

Methods included from Adapters::PGConnection

#delete, #file_length, #read, #write

Methods included from Adapters::JDBCConnection

#delete, #file_length, #read, #write

Constructor Details

#initialize(uploader) ⇒ File

Returns a new instance of File.



12
13
14
# File 'lib/carrierwave/storage/postgresql_lo.rb', line 12

def initialize(uploader)
  @uploader = uploader
end

Instance Method Details

#connectionObject



25
26
27
# File 'lib/carrierwave/storage/postgresql_lo.rb', line 25

def connection
  @connection ||= @uploader.model.class.connection.raw_connection
end

#content_typeObject



20
21
# File 'lib/carrierwave/storage/postgresql_lo.rb', line 20

def content_type
end

#identifierObject



29
30
31
# File 'lib/carrierwave/storage/postgresql_lo.rb', line 29

def identifier
  @oid ||= @uploader.identifier.to_i
end

#original_filenameObject



33
34
35
# File 'lib/carrierwave/storage/postgresql_lo.rb', line 33

def original_filename
  identifier.to_s
end

#urlObject



16
17
18
# File 'lib/carrierwave/storage/postgresql_lo.rb', line 16

def url
  "/#{@uploader.model.class.name.underscore.gsub('/', '_')}_#{@uploader.mounted_as.to_s.underscore}/#{identifier}"
end