class MountableFileServer::Adapter

Attributes

configuration[R]

Public Class Methods

new(configuration = MountableFileServer.config) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 9
def initialize(configuration = MountableFileServer.config)
  @configuration = configuration
end

Public Instance Methods

move_to_permanent_storage(uid) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 25
def move_to_permanent_storage(uid)
  uid = UniqueIdentifier.new uid
  Storage.new(configuration).move_to_permanent_storage uid
end
pathname_for(uid) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 40
def pathname_for(uid)
  uid = UniqueIdentifier.new uid
  FileAccessor.new(uid, configuration).pathname
end
remove_from_storage(uid) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 30
def remove_from_storage(uid)
  uid = UniqueIdentifier.new uid
  Storage.new(configuration).remove_from_storage uid
end
store_permanent(input, type, extension) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 19
def store_permanent(input, type, extension)
  uid = generate_random_uid type, extension
  Storage.new(configuration).store_permanent uid, input
  uid
end
store_temporary(input, type, extension) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 13
def store_temporary(input, type, extension)
  uid = generate_random_uid type, extension
  Storage.new(configuration).store_temporary uid, input
  uid
end
url_for(uid) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 35
def url_for(uid)
  uid = UniqueIdentifier.new uid
  FileAccessor.new(uid, configuration).url
end

Private Instance Methods

generate_random_uid(type, extension) click to toggle source
# File lib/mountable_file_server/adapter.rb, line 46
def generate_random_uid(type, extension)
  loop do
    uid = UniqueIdentifier.generate_for type, extension
    break uid unless FileAccessor.new(uid, configuration).exist?
  end
end