Sha256: aac8604c793c67ec38ea7eafb226aa8caf06ff9fed4bd997e34d16a61118eddb

Contents?: true

Size: 576 Bytes

Versions: 6

Compression:

Stored size: 576 Bytes

Contents

# frozen_string_literal: true

module Koi
  module SummaryList
    class AttachmentComponent < Base
      def initialize(model, attribute, variant: :thumb, **attributes)
        super(model, attribute, **attributes)

        @variant = variant
      end

      def attribute_value
        if raw_value.try(:representable?)
          image_tag(@variant.nil? ? raw_value : raw_value.variant(@variant))
        elsif raw_value.try(:attached?)
          link_to raw_value.blob.filename, rails_blob_path(raw_value, disposition: :attachment)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
katalyst-koi-4.5.5 app/components/koi/summary_list/attachment_component.rb
katalyst-koi-4.5.4 app/components/koi/summary_list/attachment_component.rb
katalyst-koi-4.5.3 app/components/koi/summary_list/attachment_component.rb
katalyst-koi-4.5.2 app/components/koi/summary_list/attachment_component.rb
katalyst-koi-4.5.1 app/components/koi/summary_list/attachment_component.rb
katalyst-koi-4.5.0 app/components/koi/summary_list/attachment_component.rb