Module: StimulusPlumbers::Plumber::Renderer::ClassMethods

Defined in:
lib/stimulus_plumbers/plumber/renderer.rb

Instance Method Summary collapse

Instance Method Details

#renders(method_name, with: nil, slots: nil, by: nil, &block) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/stimulus_plumbers/plumber/renderer.rb', line 44

def renders(method_name, with: nil, slots: nil, by: nil, &block)
  validate!(method_name, with, slots, by, block_given?)
  with = block if block_given?

  if slots.present?
    by = Class.new(StimulusPlumbers::Plumber::Slots)
    by.slot(*slots)
  end
  self.renderers = renderers.merge(method_name => { with: with, by: by })

  generate_renderer_method(method_name)
  generate_slot_method(method_name)
end