Class: Admin::Image

Inherits:
Image
  • Object
show all
Defined in:
lib/ecrire/app/models/admin/image.rb

Defined Under Namespace

Classes: S3

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#s3Object (readonly)

Returns the value of attribute s3.



8
9
10
# File 'lib/ecrire/app/models/admin/image.rb', line 8

def s3
  @s3
end

Instance Method Details

#clear!Object



19
20
21
22
23
24
25
26
# File 'lib/ecrire/app/models/admin/image.rb', line 19

def clear!
  return if self.url.nil?

  s3.bucket.objects.find(key).destroy
  self.url = nil
  self.key = nil
  save!
end

#file=(file) ⇒ Object



14
15
16
17
# File 'lib/ecrire/app/models/admin/image.rb', line 14

def file=(file)
  @file = s3.bucket.objects.build path(file)
  @file.content = file
end