Class: Spotlight::FeaturedImageRepresenter

Inherits:
Roar::Decorator
  • Object
show all
Includes:
Roar::JSON
Defined in:
app/serializers/spotlight/featured_image_representer.rb

Overview

Serialize mastheads and thumbnails

Instance Method Summary collapse

Instance Method Details

#imageObject



13
14
15
16
17
18
19
# File 'app/serializers/spotlight/featured_image_representer.rb', line 13

def image
  file = represented.image.file

  return unless file

  { filename: file.filename, content_type: file.content_type, content: Base64.encode64(file.read) }
end

#image=(file) ⇒ Object



21
22
23
24
25
# File 'app/serializers/spotlight/featured_image_representer.rb', line 21

def image=(file)
  represented.image = CarrierWave::SanitizedFile.new tempfile: StringIO.new(Base64.decode64(file['content'])),
                                                     filename: file['filename'],
                                                     content_type: file['content_type']
end