module Shrine::Plugins::PrettyLocation::InstanceMethods

  1. lib/shrine/plugins/pretty_location.rb

Methods

Public Instance

  1. generate_location

Public Instance methods

generate_location (io, context)
[show source]
# File lib/shrine/plugins/pretty_location.rb, line 31
def generate_location(io, context)
  if context[:record]
    type = class_location(context[:record].class) if context[:record].class.name
    id   = context[:record].id if context[:record].respond_to?(:id)
  end
  name = context[:name]

  dirname, slash, basename = super.rpartition("/")
  basename = "#{context[:version]}-#{basename}" if context[:version]
  original = dirname + slash + basename

  [type, id, name, original].compact.join("/")
end