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
openproject-primer_view_components-0.33.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.25.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.32.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.32.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.29.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.29.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.23.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.28.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.28.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.27.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.26.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.25.1 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.22.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.21.1 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.25.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.24.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.21.0 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.20.1 app/lib/primer/experimental_slot_helpers.rb
primer_view_components-0.20.0 app/lib/primer/experimental_slot_helpers.rb
openproject-primer_view_components-0.23.0 app/lib/primer/experimental_slot_helpers.rb