Rename style -> style_name, to make it similar to upstream

This commit is contained in:
Max Melentiev
2018-10-09 15:14:21 +03:00
parent 9f2bd0fb97
commit dd37f2eea5

View File

@@ -34,72 +34,72 @@ module Paperclip
end
# Returns the filename, the same way as ":basename.:extension" would.
def filename attachment, style
"#{basename(attachment, style)}.#{extension(attachment, style)}"
def filename attachment, style_name
"#{basename(attachment, style_name)}.#{extension(attachment, style_name)}"
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.
def url attachment, style
def url attachment, style_name
raise InfiniteInterpolationError if attachment.options[:url].include?(":url")
attachment.url(style, false)
attachment.url(style_name, false)
end
# Returns the timestamp as defined by the <attachment>_updated_at field
def timestamp attachment, style
def timestamp attachment, style_name
attachment.instance_read(:updated_at).to_s
end
# Returns the Rails.root constant.
def rails_root attachment, style
def rails_root attachment, style_name
Rails.root
end
# Returns the Rails.env constant.
def rails_env attachment, style
def rails_env attachment, style_name
Rails.env
end
# Returns the underscored, pluralized version of the class name.
# e.g. "users" for the User class.
def class attachment, style
def class attachment, style_name
attachment.instance.class.to_s.underscore.pluralize
end
# Returns the basename of the file. e.g. "file" for "file.jpg"
def basename attachment, style
def basename attachment, style_name
attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "")
end
# Returns the extension of the file. e.g. "jpg" for "file.jpg"
# If the style has a format defined, it will return the format instead
# of the actual extension.
def extension attachment, style
((style = attachment.styles[style]) && style[:format]) ||
def extension attachment, style_name
((style_name = attachment.styles[style_name]) && style_name[:format]) ||
File.extname(attachment.original_filename).gsub(/^\.+/, "")
end
# Returns the id of the instance.
def id attachment, style
def id attachment, style_name
attachment.instance.id
end
# Returns the id of the instance in a split path form. e.g. returns
# 000/001/234 for an id of 1234.
def id_partition attachment, style
def id_partition attachment, style_name
("%09d" % attachment.instance.id).scan(/\d{3}/).join("/")
end
# Returns the pluralized form of the attachment name. e.g.
# "avatars" for an attachment of :avatar
def attachment attachment, style
def attachment attachment, style_name
attachment.name.to_s.downcase.pluralize
end
# Returns the style, or the default style if nil is supplied.
def style attachment, style
style || attachment.default_style
def style attachment, style_name
style_name || attachment.default_style
end
end
end