Sha256: 87609177f8cefbf75e963221131fb63c22590bf50d5bcd6c1d39bb4062f9ff69

Contents?: true

Size: 767 Bytes

Versions: 4

Compression:

Stored size: 767 Bytes

Contents

module Spina
  module Parts
    class Image < Base
      attr_json :image_id, :integer, default: nil
      attr_json :signed_blob_id, :string, default: nil
      attr_json :alt, :string, default: ""
      attr_json :filename, :string, default: ""

      def to_s
        alt.presence || filename.presence || Spina::Image.model_name.human
      end

      def content
        self
      end

      def svg?
        filename =~ /\.svg\z/
      end

      def spina_image
        Spina::Image.find_by(id: image_id)
      end

      def present?
        signed_blob_id.present?
      end
      
      def signed_id
        signed_blob_id
      end
      
      def variant(options)
        Spina::Parts::ImageVariant.new(self, options)
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spina-2.0.2 app/models/spina/parts/image.rb
spina-2.0.1 app/models/spina/parts/image.rb
spina-2.0.0 app/models/spina/parts/image.rb
spina-2.0.0.beta app/models/spina/parts/image.rb