Module: Vident::StimulusComponent
- Extended by:
- ActiveSupport::Concern
- Includes:
- StimulusAttributes
- Included in:
- Component
- Defined in:
- lib/vident/stimulus_component.rb
Class Method Summary collapse
-
.stimulus_identifier_from_path(path) ⇒ Object
Module utilities for working with Stimulus identifiers.
Instance Method Summary collapse
-
#component_name ⇒ Object
An name that can helps identify the component type in the DOM or for styling purposes (its also used as a class name on the root element).
-
#default_controller_path ⇒ Object
The ‘component` class name is used to create the controller name.
-
#outlet_id ⇒ Object
If connecting an outlet to this specific component instance, use this ID.
-
#stimulus_identifier ⇒ Object
The Stimulus controller identifier for this component.
Methods included from StimulusAttributes
#add_stimulus_actions, #add_stimulus_classes, #add_stimulus_controllers, #add_stimulus_outlets, #add_stimulus_targets, #add_stimulus_values, #stimulus_action, #stimulus_actions, #stimulus_class, #stimulus_classes, #stimulus_controller, #stimulus_controllers, #stimulus_outlet, #stimulus_outlets, #stimulus_scoped_event, #stimulus_scoped_event_on_window, #stimulus_target, #stimulus_targets, #stimulus_value, #stimulus_values
Class Method Details
.stimulus_identifier_from_path(path) ⇒ Object
Module utilities for working with Stimulus identifiers
11 12 13 |
# File 'lib/vident/stimulus_component.rb', line 11 def stimulus_identifier_from_path(path) path.split("/").map { |p| p.to_s.dasherize }.join("--") end |
Instance Method Details
#component_name ⇒ Object
An name that can helps identify the component type in the DOM or for styling purposes (its also used as a class name on the root element)
68 |
# File 'lib/vident/stimulus_component.rb', line 68 def component_name = self.class.component_name |
#default_controller_path ⇒ Object
The ‘component` class name is used to create the controller name. The path of the Stimulus controller when none is explicitly set
72 |
# File 'lib/vident/stimulus_component.rb', line 72 def default_controller_path = self.class.stimulus_identifier_path |
#outlet_id ⇒ Object
If connecting an outlet to this specific component instance, use this ID
60 61 62 |
# File 'lib/vident/stimulus_component.rb', line 60 def outlet_id @outlet_id ||= [stimulus_identifier, "##{id}"] end |
#stimulus_identifier ⇒ Object
The Stimulus controller identifier for this component
65 |
# File 'lib/vident/stimulus_component.rb', line 65 def stimulus_identifier = self.class.stimulus_identifier |