Module: Kilt::Upload

Defined in:
lib/kilt/upload.rb,
lib/kilt/upload/s3.rb,
lib/kilt/upload/local.rb

Defined Under Namespace

Modules: Local, S3

Class Method Summary collapse

Class Method Details

.do(type, file_reference) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/kilt/upload.rb', line 9

def self.do(type, file_reference)
  uploader = begin
               strategy = Kilt.config.storage.strategy.to_s
               "Kilt::Upload::#{strategy.classify}".constantize
             rescue
               nil
             end
  uploader.upload(type, file_reference) if uploader
end

.method_missing(meth, *args, &blk) ⇒ Object



20
21
22
# File 'lib/kilt/upload.rb', line 20

def method_missing(meth, *args, &blk)
  self.do meth.to_s, args[0]
end

.uploadable_fieldsObject



4
5
6
7
# File 'lib/kilt/upload.rb', line 4

def self.uploadable_fields
  types = ['file', 'image'] + Kilt.config.uploadable_fields.to_s.split(',').map { |x| x.strip }
  types.group_by { |x| x }.map { |x| x[0] }
end