Class: Vident::StimulusParam

Inherits:
StimulusAttributeBase show all
Defined in:
lib/vident/stimulus_param.rb

Overview

‘data-<controller>-<name>-param=“…”` — readable on the JS side as `event.params.<camelName>`. Element-scoped: every action on the element sees the same params.

Instance Attribute Summary collapse

Attributes inherited from StimulusAttributeBase

#implied_controller

Instance Method Summary collapse

Methods inherited from StimulusAttributeBase

#implied_controller_name, #implied_controller_path, #initialize, #inspect, js_name, stimulize_path, #to_h

Constructor Details

This class inherits a constructor from Vident::StimulusAttributeBase

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



8
9
10
# File 'lib/vident/stimulus_param.rb', line 8

def controller
  @controller
end

#param_nameObject (readonly)

Returns the value of attribute param_name.



8
9
10
# File 'lib/vident/stimulus_param.rb', line 8

def param_name
  @param_name
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/vident/stimulus_param.rb', line 8

def value
  @value
end

Instance Method Details

#data_attribute_nameObject



12
# File 'lib/vident/stimulus_param.rb', line 12

def data_attribute_name = "#{@controller}-#{@param_name}-param"

#data_attribute_valueObject



14
# File 'lib/vident/stimulus_param.rb', line 14

def data_attribute_value = @value

#to_sObject



10
# File 'lib/vident/stimulus_param.rb', line 10

def to_s = @value.to_s