lib/erlectricity/conditions/hash.rb in erlectricity-0.2.1 vs lib/erlectricity/conditions/hash.rb in erlectricity-1.0.0

- old
+ new

@@ -1,14 +1,13 @@ module Erlectricity -class HashCondition < Condition + class HashCondition < Condition + def satisfies?(arg) + return false unless arg.class == Array + arg.all? { |x| x.class == Array && x.length == 2 } + end - def satisfies?(arg) - return false unless arg.class == Array - arg.all?{|x| x.class == Array && x.length == 2} + def binding_for(arg) + flattened = arg.inject([]) { |memo, kv| memo + kv } + Hash[*flattened] + end end - - def binding_for(arg) - flattened = arg.inject([]){|memo, kv| memo + kv} - Hash[*flattened] - end -end end \ No newline at end of file