Sha256: b92d2865e3d68fd57238087d5e2667f619a3160a3f20b0da9ff5cc3b51a7335c

Contents?: true

Size: 795 Bytes

Versions: 51

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module Ingredients
    # A link to a file
    #
    # Attach Alchemy::Attachment into this ingredient
    #
    class File < Alchemy::Ingredient
      store_accessor :data,
        :css_class,
        :link_text,
        :title

      allow_settings %i[
        css_classes
        except
        link_text
        only
      ]

      related_object_alias :attachment, class_name: "Alchemy::Attachment"

      delegate :name, to: :attachment, allow_nil: true

      # The first 30 characters of the attachments name
      #
      # Used by the Element#preview_text method.
      #
      # @param [Integer] max_length (30)
      #
      def preview_text(max_length = 30)
        attachment&.name.to_s[0..max_length - 1]
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
alchemy_cms-7.3.5 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.2.8 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.1.13 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.0.16 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.3.4 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.3.3 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.3.2 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.2.7 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.3.1 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.3.0 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.2.6 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.2.5 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.1.12 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.0.15 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.2.4 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.1.11 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.2.3 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.1.10 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.2.2 app/models/alchemy/ingredients/file.rb
alchemy_cms-7.1.9 app/models/alchemy/ingredients/file.rb