lib/paperclip/interpolations.rb in paperclip-2.3.11 vs lib/paperclip/interpolations.rb in paperclip-2.3.12
- old
+ new
@@ -4,17 +4,17 @@
# can either open this module and define it, or call the
# Paperclip.interpolates method.
module Interpolations
extend self
- # Hash assignment of interpolations. Included only for compatability,
+ # Hash assignment of interpolations. Included only for compatibility,
# and is not intended for normal use.
def self.[]= name, block
define_method(name, &block)
end
- # Hash access of interpolations. Included only for compatability,
+ # Hash access of interpolations. Included only for compatibility,
# and is not intended for normal use.
def self.[] name
method(name)
end
@@ -33,11 +33,11 @@
end
end
# Returns the filename, the same way as ":basename.:extension" would.
def filename attachment, style_name
- "#{basename(attachment, style_name)}.#{extension(attachment, style_name)}"
+ [ basename(attachment, style_name), extension(attachment, style_name) ].reject(&:blank?).join(".")
end
# Returns the interpolated URL. Will raise an error if the url itself
# contains ":url" to prevent infinite recursion. This interpolation
# is used in the default :path to ease default specifications.
@@ -95,9 +95,14 @@
end
# Returns the id of the instance.
def id attachment, style_name
attachment.instance.id
+ end
+
+ # Returns the #to_param of the instance.
+ def param attachment, style_name
+ attachment.instance.to_param
end
# Returns the fingerprint of the instance.
def fingerprint attachment, style_name
attachment.fingerprint