Class: Vident::StimulusTargetCollection
- Inherits:
-
StimulusCollectionBase
- Object
- StimulusCollectionBase
- Vident::StimulusTargetCollection
- Defined in:
- lib/vident/stimulus_target_collection.rb
Instance Method Summary collapse
Methods inherited from StimulusCollectionBase
#<<, #any?, #empty?, #initialize, #merge, merge, #to_a, #to_hash
Constructor Details
This class inherits a constructor from Vident::StimulusCollectionBase
Instance Method Details
#to_h ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vident/stimulus_target_collection.rb', line 5 def to_h return {} if items.empty? merged = {} items.each do |target| target.to_h.each do |key, value| merged[key] = if merged.key?(key) # Merge space-separated values for same target attribute "#{merged[key]} #{value}" else value end end end merged end |