Sha256: 54f1ae777c953507f984ee745c3e566807c3b27b412dad3a9c2e6795b2d4c531

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 KB

Contents

module Pageflow
  # Include in entry type specific configuration classes.
  #
  # @since 15.1
  module EntryTypeConfiguration
    # @api private
    def initialize(config, entry_type)
      @config = config
      @features = FeaturesDelegator.new(config, entry_type)
    end

    attr_reader :features

    delegate :file_importers, to: :@config
    delegate :file_types, to: :@config
    delegate :help_entries, to: :@config
    delegate :hooks, to: :@config
    delegate :revision_components, to: :@config
    delegate :themes, to: :@config
    delegate :widget_types, to: :@config
    delegate :transform_theme_customization_overrides=, to: :@config
    delegate :transform_theme_customization_files=, to: :@config

    def plugin(plugin)
      plugin.configure(self)
    end

    # @api private
    FeaturesDelegator = Struct.new(:config, :entry_type) do
      def register(feature, &block)
        return register(Feature.new(feature, &block)) if feature.is_a?(String)

        entry_type_feature = Feature.new(
          feature.name,
          name_translation_key: feature.name_translation_key
        ) do |feature_config|
          feature_config.for_entry_type(entry_type, &feature.method(:enable))
        end

        config.features.register(entry_type_feature)
      end

      def enable_by_default(name)
        config.features.enable_by_default(name)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/pageflow/entry_type_configuration.rb
pageflow-17.0.3 lib/pageflow/entry_type_configuration.rb
pageflow-17.0.2 lib/pageflow/entry_type_configuration.rb
pageflow-17.0.1 lib/pageflow/entry_type_configuration.rb
pageflow-17.0.0 lib/pageflow/entry_type_configuration.rb
pageflow-16.2.0 lib/pageflow/entry_type_configuration.rb
pageflow-16.1.0 lib/pageflow/entry_type_configuration.rb
pageflow-16.0.0 lib/pageflow/entry_type_configuration.rb
pageflow-15.8.0 lib/pageflow/entry_type_configuration.rb
pageflow-15.7.1 lib/pageflow/entry_type_configuration.rb
pageflow-15.7.0 lib/pageflow/entry_type_configuration.rb