Module: ScribdFu::Paperclip::InstanceMethods

Defined in:
lib/scribd_fu/paperclip.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(base)



9
10
11
# File 'lib/scribd_fu/paperclip.rb', line 9

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

- (Object) file_path

Returns the full filename for the given attribute. If the file is stored on S3, this is a full S3 URI, while it is a full path to the local file if the file is stored locally.



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/scribd_fu/paperclip.rb', line 30

def file_path
  if attached_file.options[:storage] == :s3
    if attached_file.instance_variable_get(:@s3_permissions) == "authenticated-read"
      return attached_file.expiring_url(60)
    else
      path = attached_file.url
    end
  else
    path = attached_file.path
  end

  ScribdFu::strip_cache_string(path)
end

- (Object) get_content_type

Find the content type of the associated file



14
15
16
# File 'lib/scribd_fu/paperclip.rb', line 14

def get_content_type
  self.send("#{prefix}_content_type")
end

- (Object) thumbnail_url

Returns a URL for a thumbnail for the attached file object.



19
20
21
22
23
24
25
# File 'lib/scribd_fu/paperclip.rb', line 19

def thumbnail_url
  begin
    (ipaper_document && ipaper_document.thumbnail_url) || attached_file.url(:thumb)
  rescue
    raise ScribdFu::ScribdFuError, "The thumbnail doesn't exist."
  end
end