Class: Vanguard::Rule::Guard::Evaluator

Inherits:
Evaluator
  • Object
show all
Defined in:
lib/vanguard/rule/guard.rb

Instance Attribute Summary

Attributes inherited from Evaluator

#resource, #rule

Instance Method Summary collapse

Methods inherited from Evaluator

#initialize, #value, #violation, #violations

Constructor Details

This class inherits a constructor from Vanguard::Evaluator

Instance Method Details

#valid?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if resource is valid

Returns:

  • (true)

    when guard matches and operand also

  • (false)

    otherwise



68
69
70
71
72
73
74
75
76
# File 'lib/vanguard/rule/guard.rb', line 68

def valid?
  resource = self.resource

  unless matcher.matches?(resource)
    return true
  end

  operand.evaluate(resource).valid?
end