Class: Balloon::Base
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Uploader
#save_to_cache, #set_storage_engine, #url
Class Method Details
.uploader(name) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/balloon/base.rb', line 5
def self.uploader(name)
class_eval <<-RUBY
def initialize(upload_file = nil)
set_storage_engine
@file = upload_file.is_a?(Hash) ? upload_file[:#{name}] : upload_file
end
def #{name}
@meta
end
def uploader_name
"#{name}".pluralize
end
def set_storage_engine
return if respond_to?(:@storage_engine)
@storage_engine = eval(STORAGE_EGINE[store_storage.to_sym]).new(self)
end
RUBY
end
|
Instance Method Details
#from_store(size_name = nil) ⇒ Object
39
40
41
|
# File 'lib/balloon/base.rb', line 39
def from_store(size_name = nil)
storage_engine.retrieve!(size_name)
end
|
#local_path(size_name = nil) ⇒ Object
47
48
49
|
# File 'lib/balloon/base.rb', line 47
def local_path(size_name = nil)
storage_engine.local_path!(size_name)
end
|
#path(size_name = nil) ⇒ Object
43
44
45
|
# File 'lib/balloon/base.rb', line 43
def path(size_name = nil)
storage_engine.path!(size_name)
end
|
#upload_delete ⇒ Object
51
52
53
|
# File 'lib/balloon/base.rb', line 51
def upload_delete
storage_engine.delete!
end
|
#upload_store(upload_file = nil) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/balloon/base.rb', line 31
def upload_store(upload_file = nil)
uploader_file = upload_file.nil? ? @file : upload_file
save_to_cache(uploader_file)
store_info = storage_engine.store!
@meta[:filename] = store_info[:filename]
@meta[:basename] = store_info[:basename]
end
|