Class: Erlectricity::HashCondition

Inherits:
Condition
  • Object
show all
Defined in:
lib/erlectricity/conditions/hash.rb

Instance Method Summary collapse

Methods inherited from Condition

for, #initialize

Constructor Details

This class inherits a constructor from Erlectricity::Condition

Instance Method Details

#binding_for(arg) ⇒ Object



8
9
10
11
# File 'lib/erlectricity/conditions/hash.rb', line 8

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

#satisfies?(arg) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
# File 'lib/erlectricity/conditions/hash.rb', line 3

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