Class: Vident::StimulusAttributeBase
- Inherits:
-
Object
- Object
- Vident::StimulusAttributeBase
show all
- Defined in:
- lib/vident/stimulus_attribute_base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args, implied_controller: nil) ⇒ StimulusAttributeBase
Returns a new instance of StimulusAttributeBase.
21
22
23
24
|
# File 'lib/vident/stimulus_attribute_base.rb', line 21
def initialize(*args, implied_controller: nil)
@implied_controller = implied_controller
parse_arguments(*args)
end
|
Instance Attribute Details
#implied_controller ⇒ Object
Returns the value of attribute implied_controller.
19
20
21
|
# File 'lib/vident/stimulus_attribute_base.rb', line 19
def implied_controller
@implied_controller
end
|
Class Method Details
.js_name(name) ⇒ Object
‘:my_thing` → `“myThing”`
15
16
17
|
# File 'lib/vident/stimulus_attribute_base.rb', line 15
def self.js_name(name)
name.to_s.camelize(:lower)
end
|
.stimulize_path(path) ⇒ Object
‘“admin/users”` → `“admin–users”`; accepts Symbol or String.
10
11
12
|
# File 'lib/vident/stimulus_attribute_base.rb', line 10
def self.stimulize_path(path)
path.to_s.split("/").map(&:dasherize).join("--")
end
|
Instance Method Details
#data_attribute_name ⇒ Object
34
|
# File 'lib/vident/stimulus_attribute_base.rb', line 34
def data_attribute_name = raise(NoMethodError, "Subclasses must implement data_attribute_name")
|
#data_attribute_value ⇒ Object
36
|
# File 'lib/vident/stimulus_attribute_base.rb', line 36
def data_attribute_value = raise(NoMethodError, "Subclasses must implement data_attribute_value")
|
#implied_controller_name ⇒ Object
43
44
45
46
|
# File 'lib/vident/stimulus_attribute_base.rb', line 43
def implied_controller_name
raise ArgumentError, "implied_controller is required to get implied controller name" unless implied_controller
implied_controller.name
end
|
#implied_controller_path ⇒ Object
38
39
40
41
|
# File 'lib/vident/stimulus_attribute_base.rb', line 38
def implied_controller_path
raise ArgumentError, "implied_controller is required to get implied controller path" unless implied_controller
implied_controller.path
end
|
#inspect ⇒ Object
26
|
# File 'lib/vident/stimulus_attribute_base.rb', line 26
def inspect = "#<#{self.class.name} #{to_h}>"
|
#to_h ⇒ Object
Also known as:
to_hash
30
|
# File 'lib/vident/stimulus_attribute_base.rb', line 30
def to_h = {data_attribute_name => data_attribute_value}
|
#to_s ⇒ Object
28
|
# File 'lib/vident/stimulus_attribute_base.rb', line 28
def to_s = raise(NoMethodError, "Subclasses must implement to_s")
|