Class: Paperclip::Storage::Dropbox::UrlGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip/storage/dropbox/url_generator.rb

Direct Known Subclasses

PrivateUrlGenerator, PublicUrlGenerator

Instance Method Summary collapse

Constructor Details

#initialize(attachment, attachment_options) ⇒ UrlGenerator

Returns a new instance of UrlGenerator.



8
9
10
11
# File 'lib/paperclip/storage/dropbox/url_generator.rb', line 8

def initialize(attachment, attachment_options)
  @attachment = attachment
  @attachment_options = attachment_options
end

Instance Method Details

#generate(style, options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/paperclip/storage/dropbox/url_generator.rb', line 13

def generate(style, options)
  if @attachment.present?
    url = file_url(style)
    url = URI.parse(url)
    url.query = [url.query, "dl=1"].compact.join("&") if options[:download]
    url.to_s
  else
    @attachment_options[:interpolator].interpolate(@attachment_options[:default_url], @attachment, style)
  end
end