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



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

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



23
24
25
26
27
# File 'app/serializers/spotlight/featured_image_representer.rb', line 23

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