Class: FoxTail::StimulusMerger

Inherits:
Object
  • Object
show all
Defined in:
lib/fox_tail/stimulus_merger.rb

Instance Method Summary collapse

Instance Method Details

#merge_actions(*actions) ⇒ Object



19
20
21
# File 'lib/fox_tail/stimulus_merger.rb', line 19

def merge_actions(*actions)
  actions.reject(&:blank?).join(" ").presence
end

#merge_attributes(attributes, *other_attributes) ⇒ Object



11
12
13
# File 'lib/fox_tail/stimulus_merger.rb', line 11

def merge_attributes(attributes, *other_attributes)
  merge_attributes!(attributes.deep_dup, *other_attributes)
end

#merge_attributes!(attributes, *other_attributes) ⇒ Object



5
6
7
8
9
# File 'lib/fox_tail/stimulus_merger.rb', line 5

def merge_attributes!(attributes, *other_attributes)
  attributes[:data] ||= {}
  other_attributes.each { |attr| merge_stimulus_attributes attributes, attr }
  attributes
end

#merge_controllers(*controllers) ⇒ Object



15
16
17
# File 'lib/fox_tail/stimulus_merger.rb', line 15

def merge_controllers(*controllers)
  controllers.map(&:to_s).reject(&:blank?).uniq.join(" ").presence
end