Class: Vident::StimulusAction
- Inherits:
-
StimulusAttributeBase
- Object
- StimulusAttributeBase
- Vident::StimulusAction
- Defined in:
- lib/vident/stimulus_action.rb
Defined Under Namespace
Classes: Descriptor
Constant Summary collapse
- VALID_OPTIONS =
[:once, :prevent, :stop, :passive, :"!passive", :capture, :self].freeze
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#keyboard ⇒ Object
readonly
Returns the value of attribute keyboard.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Attributes inherited from StimulusAttributeBase
Instance Method Summary collapse
- #data_attribute_name ⇒ Object
- #data_attribute_value ⇒ Object
-
#initialize(*args, implied_controller: nil) ⇒ StimulusAction
constructor
A new instance of StimulusAction.
- #to_s ⇒ Object
Methods inherited from StimulusAttributeBase
#implied_controller_name, #implied_controller_path, #inspect, js_name, stimulize_path, #to_h
Constructor Details
#initialize(*args, implied_controller: nil) ⇒ StimulusAction
Returns a new instance of StimulusAction.
22 23 24 25 26 27 |
# File 'lib/vident/stimulus_action.rb', line 22 def initialize(*args, implied_controller: nil) @options = [] @keyboard = nil @window = false super end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
20 21 22 |
# File 'lib/vident/stimulus_action.rb', line 20 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
20 21 22 |
# File 'lib/vident/stimulus_action.rb', line 20 def controller @controller end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
20 21 22 |
# File 'lib/vident/stimulus_action.rb', line 20 def event @event end |
#keyboard ⇒ Object (readonly)
Returns the value of attribute keyboard.
20 21 22 |
# File 'lib/vident/stimulus_action.rb', line 20 def keyboard @keyboard end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/vident/stimulus_action.rb', line 20 def @options end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
20 21 22 |
# File 'lib/vident/stimulus_action.rb', line 20 def window @window end |
Instance Method Details
#data_attribute_name ⇒ Object
43 |
# File 'lib/vident/stimulus_action.rb', line 43 def data_attribute_name = "action" |
#data_attribute_value ⇒ Object
45 |
# File 'lib/vident/stimulus_action.rb', line 45 def data_attribute_value = to_s |
#to_s ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vident/stimulus_action.rb', line 29 def to_s head = if @event ev = @event.to_s ev = "#{ev}.#{@keyboard}" if @keyboard ev = "#{ev}#{@options.map { |o| ":#{o}" }.join}" if @options.any? ev = "#{ev}@window" if @window "#{ev}->" else "" end "#{head}#{@controller}##{@action}" end |