Sha256: 9b1d467d66b9f327d10cc43292b5bb534a66f4081843f5b0c2b0a10d9c079e6d
Contents?: true
Size: 884 Bytes
Versions: 7
Compression:
Stored size: 884 Bytes
Contents
# frozen_string_literal: true require 'roar/decorator' require 'roar/json' module Spotlight ## # Serialize mastheads and thumbnails class FeaturedImageRepresenter < Roar::Decorator include Roar::JSON (Spotlight::FeaturedImage.attribute_names - %w[id image]).each do |prop| property prop end property :image, exec_context: :decorator def image file = represented.image.file return unless file { filename: file.filename, content_type: file.content_type, content: Base64.encode64(file.read) } end def image=(file) represented.image = CarrierWave::SanitizedFile.new tempfile: StringIO.new(Base64.decode64(file['content'])), filename: file['filename'], content_type: file['content_type'] end end end
Version data entries
7 entries across 7 versions & 1 rubygems