Module: Weft::DSL::Inclusions::ClassMethods
- Defined in:
- lib/weft/dsl/inclusions.rb
Instance Method Summary collapse
-
#includes(component_class, on: nil, &block) ⇒ Object
Declare that another component should be OOB-swapped alongside this component's action responses and SSE pushes.
-
#inclusions ⇒ Object
All declared inclusions (own + inherited).
Instance Method Details
#includes(component_class, on: nil, &block) ⇒ Object
Declare that another component should be OOB-swapped alongside this component's action responses and SSE pushes.
includes OrderHeader # pass-through attrs
includes OrderHeader, on: :advance # only on :advance action
includes OrderHeader do |attrs| # explicit attr mapping
{ order_id: attrs.order_id, compact: true }
end
Without a block, the included component resolves from the same request params as the primary component. With a block, the block receives the primary component's resolved attrs and returns wire attrs for the included component's Resolver.
28 29 30 |
# File 'lib/weft/dsl/inclusions.rb', line 28 def includes(component_class, on: nil, &block) own_inclusions << { component_class: component_class, on: on, block: block } end |
#inclusions ⇒ Object
All declared inclusions (own + inherited).
33 34 35 36 37 38 39 |
# File 'lib/weft/dsl/inclusions.rb', line 33 def inclusions if superclass.respond_to?(:inclusions) superclass.inclusions + own_inclusions else own_inclusions.dup end end |