Sha256: a99c15219de1247a191f3c9c3a5eb498f3b2c1f586f941eac730eb2ebead10bf

Contents?: true

Size: 814 Bytes

Versions: 8

Compression:

Stored size: 814 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: ""

      attr_accessor :options

      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(expires_in: nil)
        signed_blob_id
      end
      
      def variant(options)
        Spina::Parts::ImageVariant.new(self, options)
      end
      
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spina-2.12.0 app/models/spina/parts/image.rb
spina-2.11.0 app/models/spina/parts/image.rb
spina-2.10.0 app/models/spina/parts/image.rb
spina-2.9.1 app/models/spina/parts/image.rb
spina-2.9.0 app/models/spina/parts/image.rb
spina-2.8.1 app/models/spina/parts/image.rb
spina-2.8.0 app/models/spina/parts/image.rb
spina-2.7.0 app/models/spina/parts/image.rb