Module: ViewComponent::PolymorphicSlots::InstanceMethods

Defined in:
lib/view_component/polymorphic_slots.rb

Instance Method Summary collapse

Instance Method Details

#set_polymorphic_slot(slot_name, poly_type = nil, *args, &block) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/view_component/polymorphic_slots.rb', line 68

def set_polymorphic_slot(slot_name, poly_type = nil, *args, &block)
  slot_definition = self.class.registered_slots[slot_name]

  if !slot_definition[:collection] && get_slot(slot_name)
    raise ArgumentError, "content for slot '#{slot_name}' has already been provided"
  end

  poly_def = slot_definition[:renderable_hash][poly_type]

  set_slot(slot_name, poly_def, *args, &block)
end