Class: Mutations::SimpleHashFilter

Inherits:
AdditionalFilter
  • Object
show all
Defined in:
lib/hyper-operation/filters/simple_hash.rb

Instance Method Summary collapse

Instance Method Details

#filter(data) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hyper-operation/filters/simple_hash.rb', line 7

def filter(data)

  # Handle nil case
  if data.nil?
    return [nil, nil] if options[:nils]
    return [nil, :nils]
  end
  
  # Now check if it's empty:
  return [data, :empty] if data == {}

  # If data is a hash, we win.
  return [data, nil] if data.is_a? Hash
end