Module: DeepHashTransformer::CollectionOperation

Defined in:
lib/deep_hash_transformer/collection_operation.rb

Class Method Summary collapse

Class Method Details

.compact(val) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/deep_hash_transformer/collection_operation.rb', line 8

def compact(val)
  case val
  when Array, Hash
    val.compact
  else
    val
  end
end

.compact_blank(val) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/deep_hash_transformer/collection_operation.rb', line 17

def compact_blank(val)
  case val
  when Array
    val.reject { |elem| Blank.call(elem) }
  when Hash
    val.reject { |_, v| Blank.call(v) }
  else
    val
  end
end