Sha256: 0acb2b899c14f3ac37c45c2c87abfa33587d77fc7fb789deca5d7071cbc27c47

Contents?: true

Size: 312 Bytes

Versions: 8

Compression:

Stored size: 312 Bytes

Contents

module Erlectricity
  class HashCondition < Condition
    def satisfies?(arg)
      return false unless arg.class == Array
      arg.all? { |x| x.class == Array && x.length == 2 }
    end

    def binding_for(arg)
      flattened = arg.inject([]) { |memo, kv| memo + kv }
      Hash[*flattened]
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
mojombo-erlectricity-1.0.0 lib/erlectricity/conditions/hash.rb
mojombo-erlectricity-1.0.1 lib/erlectricity/conditions/hash.rb
mojombo-erlectricity-1.0.2 lib/erlectricity/conditions/hash.rb
erlectricity-funbox-1.1.2 lib/erlectricity/conditions/hash.rb
erlectricity-1.1.1 lib/erlectricity/conditions/hash.rb
erlectricity-1.1.0 lib/erlectricity/conditions/hash.rb
erlectricity-1.0.0 lib/erlectricity/conditions/hash.rb
erlectricity-1.0.1 lib/erlectricity/conditions/hash.rb