Class: CircuitBreaker::Rules::RuleResult
- Inherits:
-
Object
- Object
- CircuitBreaker::Rules::RuleResult
- Defined in:
- lib/circuit_breaker/rules.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Instance Method Summary collapse
- #&(other) ⇒ Object
-
#initialize(valid, errors = []) ⇒ RuleResult
constructor
A new instance of RuleResult.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
- #|(other) ⇒ Object
Constructor Details
#initialize(valid, errors = []) ⇒ RuleResult
Returns a new instance of RuleResult.
11 12 13 14 |
# File 'lib/circuit_breaker/rules.rb', line 11 def initialize(valid, errors = []) @valid = valid @errors = Array(errors) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/circuit_breaker/rules.rb', line 9 def errors @errors end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
9 10 11 |
# File 'lib/circuit_breaker/rules.rb', line 9 def valid @valid end |
Instance Method Details
#&(other) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/circuit_breaker/rules.rb', line 24 def &(other) RuleResult.new( valid? && other.valid?, errors + other.errors ) end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/circuit_breaker/rules.rb', line 20 def to_s valid? ? "valid" : "invalid: #{errors.join(', ')}" end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/circuit_breaker/rules.rb', line 16 def valid? @valid end |
#|(other) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/circuit_breaker/rules.rb', line 31 def |(other) RuleResult.new( valid? || other.valid?, valid? || other.valid? ? [] : errors + other.errors ) end |