Module: Vident::StimulusAttributes

Extended by:
ActiveSupport::Concern, Vident::Stimulus::Naming
Includes:
Vident::Stimulus::Naming
Included in:
StimulusComponent
Defined in:
lib/vident/stimulus_attributes.rb

Instance Method Summary collapse

Methods included from Vident::Stimulus::Naming

collection_ivar, mutator_method, prop_ivar

Instance Method Details

#stimulus_action(*args) ⇒ Object



66
67
68
69
# File 'lib/vident/stimulus_attributes.rb', line 66

def stimulus_action(*args)
  return args.first if args.length == 1 && args.first.is_a?(StimulusAction)
  StimulusAction.new(*args, implied_controller:)
end

#stimulus_class(*args) ⇒ Object



93
94
95
96
# File 'lib/vident/stimulus_attributes.rb', line 93

def stimulus_class(*args)
  return args.first if args.length == 1 && args.first.is_a?(StimulusClass)
  StimulusClass.new(*args, implied_controller:)
end

#stimulus_controller(*args) ⇒ Object



27
28
29
30
# File 'lib/vident/stimulus_attributes.rb', line 27

def stimulus_controller(*args)
  return args.first if args.length == 1 && args.first.is_a?(StimulusController)
  StimulusController.new(*args, implied_controller: implied_controller_path)
end

#stimulus_outlet(*args) ⇒ Object

‘component_id: @id` scopes the auto-generated selector to this component instance (e.g. `#<host-id> [data-controller~=<outlet>]`).



78
79
80
81
# File 'lib/vident/stimulus_attributes.rb', line 78

def stimulus_outlet(*args)
  return args.first if args.length == 1 && args.first.is_a?(StimulusOutlet)
  StimulusOutlet.new(*args, implied_controller:, component_id: @id)
end

#stimulus_param(*args) ⇒ Object



88
89
90
91
# File 'lib/vident/stimulus_attributes.rb', line 88

def stimulus_param(*args)
  return args.first if args.length == 1 && args.first.is_a?(StimulusParam)
  StimulusParam.new(*args, implied_controller:)
end

#stimulus_scoped_event(event) ⇒ Object



110
# File 'lib/vident/stimulus_attributes.rb', line 110

def stimulus_scoped_event(event) = self.class.stimulus_scoped_event(event)

#stimulus_scoped_event_on_window(event) ⇒ Object



112
# File 'lib/vident/stimulus_attributes.rb', line 112

def stimulus_scoped_event_on_window(event) = self.class.stimulus_scoped_event_on_window(event)

#stimulus_target(*args) ⇒ Object



71
72
73
74
# File 'lib/vident/stimulus_attributes.rb', line 71

def stimulus_target(*args)
  return args.first if args.length == 1 && args.first.is_a?(StimulusTarget)
  StimulusTarget.new(*args, implied_controller:)
end

#stimulus_value(*args) ⇒ Object



83
84
85
86
# File 'lib/vident/stimulus_attributes.rb', line 83

def stimulus_value(*args)
  return args.first if args.length == 1 && args.first.is_a?(StimulusValue)
  StimulusValue.new(*args, implied_controller:)
end