Module: Impulse::Helpers::AttributesHelper
- Included in:
- ApplicationComponent
- Defined in:
- lib/impulse/helpers/attributes_helper.rb
Instance Method Summary collapse
-
#merge_attributes(*args) ⇒ Object
Merges hashes that contain keys and nested keys.
Instance Method Details
#merge_attributes(*args) ⇒ Object
Merges hashes that contain keys and nested keys. Eg. merge_attributes({ target: “item” }, action: “click->action”)
> { target: “item”, action: “click->action” }
You can use this method to merge data attributes and system args. Eg. @system_args = merge_attributes(system_args, action: “click->action”)
10 11 12 13 14 15 |
# File 'lib/impulse/helpers/attributes_helper.rb', line 10 def merge_attributes(*args) args = args.map { |el| el.presence || {} } args.first.deep_merge(args.second) do |_key, val, other_val| val + " #{other_val}" end end |