Sha256: aac3e8f870838e626e4c8d16d3fe6171cefe574570050d6cc0f46762c721fa88

Contents?: true

Size: 887 Bytes

Versions: 5

Compression:

Stored size: 887 Bytes

Contents

module PageflowScrolled
  # Register additonal Webpacker packs to be loaded in entries.
  class AdditionalPacks
    # @api private
    def initialize
      @packs = []
    end

    # content_element_type_names option only takes effect for frontend
    # packs.
    def register(path, content_element_type_names: [])
      @packs << AdditionalPack.new(path, content_element_type_names)
    end

    # @api private
    def content_element_type_names
      @packs
        .flat_map(&:content_element_type_names)
        .uniq
    end

    # @api private
    def paths
      @packs.map(&:path)
    end

    # @api private
    def paths_for_content_element_types(type_names)
      @packs.reject { |pack|
        (pack.content_element_type_names & type_names).empty?
      }.map(&:path)
    end

    # @api private
    AdditionalPack = Struct.new(:path, :content_element_type_names)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pageflow-16.1.0 entry_types/scrolled/lib/pageflow_scrolled/additional_packs.rb
pageflow-16.0.0 entry_types/scrolled/lib/pageflow_scrolled/additional_packs.rb
pageflow-15.8.0 entry_types/scrolled/lib/pageflow_scrolled/additional_packs.rb
pageflow-15.7.1 entry_types/scrolled/lib/pageflow_scrolled/additional_packs.rb
pageflow-15.7.0 entry_types/scrolled/lib/pageflow_scrolled/additional_packs.rb