Permalink
Browse files

Delegate Attachment#url through to the vault, too.

  • Loading branch information...
1 parent 6a03ce0 commit 10f788a33f05fef58d9809c0f10f69e0f78159ee @mike-burns mike-burns committed Dec 18, 2011
Showing with 12 additions and 8 deletions.
  1. +1 −8 lib/paperclip/attachment.rb
  2. +11 −0 lib/paperclip/shim_vault.rb
@@ -76,7 +76,6 @@ def initialize(name, instance, options = {})
@errors = {}
@dirty = false
@interpolator = options[:interpolator]
- @url_generator = options[:url_generator].new(self, @options)
@source_file_options = options[:source_file_options]
@whiny = options[:whiny]
@vault = options[:vault].new(self, @options)
@@ -151,13 +150,7 @@ def assign uploaded_file
# +#new(Paperclip::Attachment, options_hash)+
# +#for(style_name, options_hash)+
def url(style_name = default_style, options = {})
- default_options = {:timestamp => @options[:use_timestamp], :escape => true}
-
- if options == true || options == false # Backwards compatibility.
- @url_generator.for(style_name, default_options.merge(:timestamp => options))
- else
- @url_generator.for(style_name, default_options.merge(options))
- end
+ @vault.url(style_name, options)
end
# Returns the path of the attachment as defined by the :path option. If the
@@ -10,6 +10,7 @@ def initialize(attachment, options)
@queued_for_delete = []
@options = options
@attachment = attachment
+ @url_generator = options[:url_generator].new(@attachment, @options)
initialize_storage
end
@@ -37,6 +38,16 @@ def destroy(styles)
save
end
+ def url(style_name = default_style, options = {})
+ default_options = {:timestamp => @options[:use_timestamp], :escape => true}
+
+ if options == true || options == false # Backwards compatibility.
+ @url_generator.for(style_name, default_options.merge(:timestamp => options))
+ else
+ @url_generator.for(style_name, default_options.merge(options))
+ end
+ end
+
def path(style_name = default_style)
if file_attached?
path = interpolate(path_option, style_name)

0 comments on commit 10f788a

Please sign in to comment.