Class: DirectWave::Uploader::Base

Inherits:
Object
  • Object
show all
Includes:
Accreditation, Configuration, Connection, Paths, Versions
Defined in:
lib/directwave/uploader/uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Versions

#versions

Methods included from Paths

#default_url, #filename, #has_store_key?, #key, #original_filename, #store_key, #store_key=, #url

Methods included from Accreditation

#s3_acl, #s3_policy, #s3_signature

Constructor Details

#initialize(model = nil, mounted_as = nil) ⇒ Base

Returns a new instance of Base.



13
14
15
16
# File 'lib/directwave/uploader/uploader.rb', line 13

def initialize(model=nil, mounted_as=nil)
  @model      = model
  @mounted_as = mounted_as
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



11
12
13
# File 'lib/directwave/uploader/uploader.rb', line 11

def model
  @model
end

#mounted_asObject (readonly)

Returns the value of attribute mounted_as.



11
12
13
# File 'lib/directwave/uploader/uploader.rb', line 11

def mounted_as
  @mounted_as
end

Instance Method Details

#destroyObject



30
31
32
# File 'lib/directwave/uploader/uploader.rb', line 30

def destroy
  versions.each { |name, version| version.delete }
end

#global_processObject



34
# File 'lib/directwave/uploader/uploader.rb', line 34

def global_process; end

#saveObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/directwave/uploader/uploader.rb', line 18

def save
  if has_store_key?
    # at first remove previous files
    versions.each { |name, version| version.delete } unless model[mounted_as].blank?
 
    # at second process new files
    model[mounted_as] = filename
    versions.each { |name, version| version.process }
    global_process
  end
end