Class: Paperdragon::File

Inherits:
Object
  • Object
show all
Includes:
Delete, Process, Rename, Reprocess
Defined in:
lib/paperdragon/file.rb,
lib/paperdragon/file/operations.rb

Overview

A physical file with a UID.

Files are usually created via an Attachment instance. You can call processing methods on file instances. This will save the file and return the new metadata hash.

file = Paperdragon::File.new(uid)

 = file.reprocess! do |job|
  job.thumb!("16x16")
end

Defined Under Namespace

Modules: Delete, Process, Rename, Reprocess

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Rename

#rename!

Methods included from Reprocess

#reprocess!

Methods included from Delete

#delete!

Methods included from Process

#process!

Constructor Details

#initialize(uid, options = {}) ⇒ File

Returns a new instance of File.



14
15
16
17
18
# File 'lib/paperdragon/file.rb', line 14

def initialize(uid, options={})
  @uid     = uid
  @options = options
  @data    = nil # DISCUSS: do we need that here?
end

Instance Attribute Details

#optionsObject (readonly) Also known as: metadata

Returns the value of attribute options.



20
21
22
# File 'lib/paperdragon/file.rb', line 20

def options
  @options
end

#uidObject (readonly)

Returns the value of attribute uid.



20
21
22
# File 'lib/paperdragon/file.rb', line 20

def uid
  @uid
end

Instance Method Details

#dataObject



27
28
29
30
# File 'lib/paperdragon/file.rb', line 27

def data
  puts "........................FETCH  (data): #{uid}, #{@data ? :cached : (:fetching)}"
  @data ||= Dragonfly.app.fetch(uid).data
end

#url(opts = {}) ⇒ Object



23
24
25
# File 'lib/paperdragon/file.rb', line 23

def url(opts={})
  Dragonfly.app.remote_url_for(uid, opts)
end