class Lopata::Condition
@private
Attributes
condition[R]
positive[R]
positive?[R]
Public Class Methods
new(condition, positive: true)
click to toggle source
# File lib/lopata/condition.rb, line 5 def initialize(condition, positive: true) @condition, @positive = condition, positive end
Public Instance Methods
match?(scenario)
click to toggle source
# File lib/lopata/condition.rb, line 11 def match?(scenario) matched = match_metadata?(scenario) positive? ? matched : !matched end
match_metadata?(scenario)
click to toggle source
# File lib/lopata/condition.rb, line 16 def match_metadata?(scenario) metadata = scenario.metadata case condition when Hash condition.keys.all? { |k| metadata[k] == condition[k] } when Array condition.map { |key| metadata[key] }.all? when TrueClass, FalseClass condition else metadata[condition] end end