class Paperdragon::File

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)

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

Attributes

metadata[R]
options[R]
uid[R]

Public Class Methods

new(uid, options={}) click to toggle source
# File lib/paperdragon/file.rb, line 14
def initialize(uid, options={})
  @uid     = uid
  @options = options
  @data    = nil # DISCUSS: do we need that here?
end

Public Instance Methods

data() click to toggle source
# 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={}) click to toggle source
# File lib/paperdragon/file.rb, line 23
def url(opts={})
  Dragonfly.app.remote_url_for(uid, opts)
end

Private Instance Methods

default_metadata_for(job) click to toggle source

Override if you want to include/exclude properties in this file metadata.

# File lib/paperdragon/file.rb, line 48
def default_metadata_for(job)
  {:width => job.width, :height => job.height, :uid => uid}#, :content_type => job.mime_type}
end
metadata_for(job, additional={}) click to toggle source
# File lib/paperdragon/file.rb, line 52
def metadata_for(job, additional={})
  default_metadata_for(job).merge(additional)
end
uid!(new_uid) click to toggle source

replaces the UID.

# File lib/paperdragon/file.rb, line 43
def uid!(new_uid)
  @uid = new_uid
end