Module: Practical::Views::ElementHelper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/practical/views/element_helper.rb
Instance Method Summary collapse
-
#grab(**bindings) ⇒ Object
rubocop:enable Layout/BlockLength.
-
#mix(*args) ⇒ Object
rubocop:disable Layout/BlockLength.
Instance Method Details
#grab(**bindings) ⇒ Object
rubocop:enable Layout/BlockLength
43 44 45 46 47 48 49 |
# File 'lib/practical/views/element_helper.rb', line 43 def grab(**bindings) if bindings.size > 1 bindings.values else bindings.values.first end end |
#mix(*args) ⇒ Object
rubocop:disable Layout/BlockLength
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/practical/views/element_helper.rb', line 7 def mix(*args) args.each_with_object({}) do |object, result| result.merge!(object) do |_key, old, new| case [old, new].freeze in [Array, Array] | [Set, Set] old + new in [Array, Set] old + new.to_a in [Array, String] old + [new] in [Hash, Hash] mix(old, new) in [Set, Array] old.to_a + new in [Set, String] old.to_a + [new] in [String, Array] [old] + new in [String, Set] [old] + new.to_a in [String, String] "#{old} #{new}" in [_, nil] old else new end end result.transform_keys! do |key| key.end_with?("!") ? key.name.chop.to_sym : key end end end |