/
abstract_store.rb
35 lines (28 loc) · 968 Bytes
/
abstract_store.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class AbstractStore
class FileDoesNotExistError < RuntimeError; end
def initialize
raise "Method not implemented. Called abstract class."
end
# Set file. Returns true if success.
def set(key, tmp_file)
raise "Method not implemented. Called abstract class."
end
# Get file. Raises FileDoesNotExistError if the file does not exist.
def get(key, tmp_file)
raise "Method not implemented. Called abstract class."
end
# Delete file. Returns true if success.
# Raises FileDoesNotExistError if the file does not exist.
def delete(key)
raise "Method not implemented. Called abstract class."
end
# Return the publically accessible URL for the given key
def url(key)
raise "Method not implemented. Called abstract class."
end
private
def raise_file_error(key)
Merb.logger.error "Tried to delete #{key} but the file does not exist"
raise FileDoesNotExistError, "#{key} does not exist"
end
end