Class: LiveComponent::Action
- Inherits:
-
Object
- Object
- LiveComponent::Action
- Defined in:
- lib/live_component/action.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attr_name ⇒ Object
- #call(method_name) ⇒ Object
-
#initialize(controller_name, event_name) ⇒ Action
constructor
A new instance of Action.
- #to_attributes ⇒ Object
Constructor Details
#initialize(controller_name, event_name) ⇒ Action
Returns a new instance of Action.
5 6 7 8 |
# File 'lib/live_component/action.rb', line 5 def initialize(controller_name, event_name) @controller_name = controller_name @event_name = event_name end |
Class Method Details
.attr_name ⇒ Object
15 16 17 |
# File 'lib/live_component/action.rb', line 15 def self.attr_name :actions end |
Instance Method Details
#attr_name ⇒ Object
19 20 21 |
# File 'lib/live_component/action.rb', line 19 def attr_name self.class.attr_name end |
#call(method_name) ⇒ Object
10 11 12 13 |
# File 'lib/live_component/action.rb', line 10 def call(method_name) @method_name = method_name self end |
#to_attributes ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/live_component/action.rb', line 23 def to_attributes {}.tap do |attrs| if @method_name attrs[:"data-action"] = "#{@event_name}->#{@controller_name}##{@method_name}" end end end |