Sha256: 8ade625ed701a636a5b8643b0cbc2f64c5075ea005fa4af4ac47f2c77199e9a1

Contents?: true

Size: 1 KB

Versions: 26

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Alchemy
  module Ingredients
    # A video attachment
    #
    class Video < Alchemy::Ingredient
      store_accessor :data,
        :allow_fullscreen,
        :autoplay,
        :controls,
        :height,
        :loop,
        :muted,
        :playsinline,
        :preload,
        :width

      allow_settings %i[except 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)
        name.to_s[0..max_length - 1]
      end

      %i[
        autoplay
        controls
        loop
        muted
        playsinline
      ].each do |method|
        define_method(:"#{method}=") do |value|
          super(ActiveModel::Type::Boolean.new.cast(value))
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
alchemy_cms-7.4.2 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.3.6 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.2.9 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.4.1 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.4.0 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.3.5 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.2.8 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.1.13 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.0.16 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.3.4 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.3.3 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.3.2 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.2.7 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.3.1 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.3.0 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.2.6 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.2.5 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.1.12 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.0.15 app/models/alchemy/ingredients/video.rb
alchemy_cms-7.2.4 app/models/alchemy/ingredients/video.rb