Class: EasyAdmin::Turbo::StreamComponent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- EasyAdmin::Turbo::StreamComponent
- Defined in:
- app/components/easy_admin/turbo/stream_component.rb
Instance Method Summary collapse
-
#initialize(action:, target: nil, targets: nil, **attrs, &block) ⇒ StreamComponent
constructor
A new instance of StreamComponent.
- #view_template ⇒ Object
Methods inherited from BaseComponent
#easy_admin_url_helpers, #helpers, #rails_url_helpers
Methods included from Permissions::Component
#current_user_can?, #current_user_has_role?, #if_can, #if_has_role, #permission_attrs, #permission_button, #permission_case, #permission_classes, #permission_field, #permission_link, #unless_can, #unless_has_role
Methods included from FieldsHelper
#field_component, #render_field
Methods included from DashboardsHelper
#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes
Constructor Details
#initialize(action:, target: nil, targets: nil, **attrs, &block) ⇒ StreamComponent
Returns a new instance of StreamComponent.
4 5 6 7 8 9 10 |
# File 'app/components/easy_admin/turbo/stream_component.rb', line 4 def initialize(action:, target: nil, targets: nil, **attrs, &block) @action = action @target = target @targets = targets @attrs = attrs @block = block end |
Instance Method Details
#view_template ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/easy_admin/turbo/stream_component.rb', line 12 def view_template attrs = { action: @action }.merge(@attrs) attrs[:target] = @target if @target attrs[:targets] = @targets if @targets turbo_stream(**attrs) do if @block template do # Yield the block so callers can `render` nested components @block.call(self) end end end end |