Sha256: ff388237a7858438f9a48fd942961ebf5fc7fc3427720037da369338e48aa77a

Contents?: true

Size: 853 Bytes

Versions: 78

Compression:

Stored size: 853 Bytes

Contents

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

78 entries across 78 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.4.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.3.3 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.3.2 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.3.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.3.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.2.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.2.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.1.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.2 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.0 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.0.rc6 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.0.rc5 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.0.rc4 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.0.rc3 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.0.rc2 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-2.0.0.rc1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-1.5.1 app/serializers/spotlight/featured_image_representer.rb
blacklight-spotlight-1.4.1 app/serializers/spotlight/featured_image_representer.rb