Module: Primer::ExperimentalSlotHelpers::ClassMethods
- Defined in:
- app/lib/primer/experimental_slot_helpers.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#add_polymorphic_slot_type(slot_name:, type:, callable:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/lib/primer/experimental_slot_helpers.rb', line 12 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 |