Class: Vident::StimulusAttributeBase

Inherits:
Object
  • Object
show all
Defined in:
lib/vident/stimulus_attribute_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, implied_controller: nil) ⇒ StimulusAttributeBase

Returns a new instance of StimulusAttributeBase.



9
10
11
12
# File 'lib/vident/stimulus_attribute_base.rb', line 9

def initialize(*args, implied_controller: nil)
  @implied_controller = implied_controller
  parse_arguments(*args)
end

Instance Attribute Details

#implied_controllerObject (readonly)

Returns the value of attribute implied_controller.



7
8
9
# File 'lib/vident/stimulus_attribute_base.rb', line 7

def implied_controller
  @implied_controller
end

Instance Method Details

#data_attribute_nameObject

Raises:

  • (NoMethodError)


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

def data_attribute_name
  raise NoMethodError, "Subclasses must implement data_attribute_name"
end

#data_attribute_valueObject

Raises:

  • (NoMethodError)


32
33
34
# File 'lib/vident/stimulus_attribute_base.rb', line 32

def data_attribute_value
  raise NoMethodError, "Subclasses must implement data_attribute_value"
end

#implied_controller_nameObject

Raises:

  • (ArgumentError)


41
42
43
44
# File 'lib/vident/stimulus_attribute_base.rb', line 41

def implied_controller_name
  raise ArgumentError, "implied_controller is required to get implied controller name" unless implied_controller
  implied_controller.name
end

#implied_controller_pathObject

Raises:

  • (ArgumentError)


36
37
38
39
# File 'lib/vident/stimulus_attribute_base.rb', line 36

def implied_controller_path
  raise ArgumentError, "implied_controller is required to get implied controller path" unless implied_controller
  implied_controller.path
end

#inspectObject



14
15
16
# File 'lib/vident/stimulus_attribute_base.rb', line 14

def inspect
  "#<#{self.class.name} #{to_h}>"
end

#to_hObject Also known as: to_hash



22
23
24
# File 'lib/vident/stimulus_attribute_base.rb', line 22

def to_h
  {data_attribute_name => data_attribute_value}
end

#to_sObject

Raises:

  • (NoMethodError)


18
19
20
# File 'lib/vident/stimulus_attribute_base.rb', line 18

def to_s
  raise NoMethodError, "Subclasses must implement to_s"
end