Sha256: e2c9ad7871cd12167e29f6117e092af19a27f3a1c19c624ed7b119a1b321204f

Contents?: true

Size: 884 Bytes

Versions: 18

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

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-3.0.0.alpha.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.13.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.12.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.12.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.11.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.10.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.9.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.8.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.7.2 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.7.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.7.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.6.1.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.6.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.6.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.5.2 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.5.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.5.0 app/serializers/spotlight/featured_image_representer.rb