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.config) ⇒ Adapter

Returns a new instance of Adapter.



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

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

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



7
8
9
# File 'lib/mountable_file_server/adapter.rb', line 7

def configuration
  @configuration
end

Instance Method Details

#move_to_permanent_storage(uid) ⇒ Object



25
26
27
28
# 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) ⇒ Object



40
41
42
43
# 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) ⇒ Object



30
31
32
33
# 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) ⇒ Object



19
20
21
22
23
# 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) ⇒ Object



13
14
15
16
17
# 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) ⇒ Object



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

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