Class: LiveComponent::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/live_component/target.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller_name, target_name) ⇒ Target

Returns a new instance of Target.



5
6
7
8
# File 'lib/live_component/target.rb', line 5

def initialize(controller_name, target_name)
  @controller_name = controller_name
  @target_name = target_name
end

Class Method Details

.attr_nameObject



14
15
16
# File 'lib/live_component/target.rb', line 14

def self.attr_name
  :targets
end

Instance Method Details

#attr_nameObject



18
19
20
# File 'lib/live_component/target.rb', line 18

def attr_name
  self.class.attr_name
end

#to_attributesObject



10
11
12
# File 'lib/live_component/target.rb', line 10

def to_attributes
  { "data-#{@controller_name}-target": @target_name.to_s }
end