Sha256: 347e2c7d86c02b838477f279e6faff0a3311b7dbf0ad729cd13d1e227b736c38

Contents?: true

Size: 755 Bytes

Versions: 95

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

module Primer
  # :nodoc:
  module ExperimentalSlotHelpers
    def self.included(base)
      base.extend(ClassMethods)
    end

    # :nodoc:
    module ClassMethods
      def add_polymorphic_slot_type(slot_name:, type:, callable:)
        slot_def = registered_slots[slot_name]
        raise "Unknown slot '#{slot_name}'" unless slot_def

        poly_def = define_slot(
          type,
          collection: slot_def[:collection],
          callable: callable
        )

        registered_slots[slot_name][:renderable_hash][type] = poly_def

        define_method(:"with_#{type}") do |**system_arguments, &block|
          set_slot(slot_name, poly_def, **system_arguments, &block)
        end
      end
    end
  end
end

Version data entries

95 entries across 95 versions & 2 rubygems

Version Path
primer_view_components-0.30.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.39.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.39.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.38.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.29.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.28.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.37.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.37.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.36.2 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.36.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.36.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.27.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.35.2 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.35.1 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.26.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.35.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.26.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.34.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.33.2 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.33.1 app/lib/primer/experimental_slot_helpers.rb