Sha256: 16a190b85ee2639040be043084f144594d712196ddd8c101aa3745c7a246b41f

Contents?: true

Size: 514 Bytes

Versions: 30

Compression:

Stored size: 514 Bytes

Contents

module Mutations
  class SimpleHashFilter < AdditionalFilter
    @default_options = {
      :nils => false   # true allows an explicit nil to be valid. Overrides any other options
    }

    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
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
hyper-operation-1.0.alpha1.8 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1.7 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1.6 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1.5 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1.4 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.99.6 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1.3 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.99.5 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.99.4 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1.2 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1.1 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.alpha1 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.99.3 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.99.2 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.99.1 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.99.0 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-1.0.0.lap28 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.5.12 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.5.11 lib/hyper-operation/filters/simple_hash.rb
hyper-operation-0.5.10 lib/hyper-operation/filters/simple_hash.rb