Class: MountableFileServer::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/mountable_file_server/adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration = MountableFileServer.configuration) ⇒ Adapter

Returns a new instance of Adapter.



5
6
7
# File 'lib/mountable_file_server/adapter.rb', line 5

def initialize(configuration = MountableFileServer.configuration)
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



3
4
5
# File 'lib/mountable_file_server/adapter.rb', line 3

def configuration
  @configuration
end

Instance Method Details

#move_to_permanent_storage(uid) ⇒ Object



21
22
23
24
# File 'lib/mountable_file_server/adapter.rb', line 21

def move_to_permanent_storage(uid)
  uid = UniqueIdentifier.new uid
  Storage.new(configuration).move_to_permanent_storage uid
end

#pathname_for(uid) ⇒ Object



36
37
38
39
# File 'lib/mountable_file_server/adapter.rb', line 36

def pathname_for(uid)
  uid = UniqueIdentifier.new uid
  FileAccessor.new(uid, configuration).pathname
end

#remove_from_permanent_storage(uid) ⇒ Object



26
27
28
29
# File 'lib/mountable_file_server/adapter.rb', line 26

def remove_from_permanent_storage(uid)
  uid = UniqueIdentifier.new uid
  Storage.new(configuration).remove_from_permanent_storage uid
end

#store_permanent(input, type, extension) ⇒ Object



15
16
17
18
19
# File 'lib/mountable_file_server/adapter.rb', line 15

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) ⇒ Object



9
10
11
12
13
# File 'lib/mountable_file_server/adapter.rb', line 9

def store_temporary(input, type, extension)
  uid = generate_random_uid type, extension
  Storage.new(configuration).store_temporary uid, input
  uid
end

#url_for(uid) ⇒ Object



31
32
33
34
# File 'lib/mountable_file_server/adapter.rb', line 31

def url_for(uid)
  uid = UniqueIdentifier.new uid
  FileAccessor.new(uid, configuration).url
end