Class: Preverus::DecisionResult
- Defined in:
- lib/preverus/results.rb
Instance Attribute Summary collapse
-
#failure_reason ⇒ Object
readonly
Returns the value of attribute failure_reason.
Attributes inherited from ApiResult
Class Method Summary collapse
Instance Method Summary collapse
- #allow? ⇒ Boolean
- #block? ⇒ Boolean
- #fallback? ⇒ Boolean
-
#initialize(data, fallback: false, failure_reason: nil) ⇒ DecisionResult
constructor
A new instance of DecisionResult.
- #recommended_action ⇒ Object
- #review? ⇒ Boolean
Methods inherited from ApiResult
Constructor Details
#initialize(data, fallback: false, failure_reason: nil) ⇒ DecisionResult
Returns a new instance of DecisionResult.
21 22 23 24 25 |
# File 'lib/preverus/results.rb', line 21 def initialize(data, fallback: false, failure_reason: nil) super(data) @fallback = fallback @failure_reason = failure_reason end |
Instance Attribute Details
#failure_reason ⇒ Object (readonly)
Returns the value of attribute failure_reason.
19 20 21 |
# File 'lib/preverus/results.rb', line 19 def failure_reason @failure_reason end |
Class Method Details
.fallback(action, reason) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/preverus/results.rb', line 27 def self.fallback(action, reason) new( { "recommended_action" => action, "risk_tier" => action == "allow" ? "unknown" : "review", "reasons" => [ { "code" => "preverus_unavailable", "severity" => action == "allow" ? "low" : "medium", "message" => "Preverus was unavailable; fallback policy was applied." } ] }, fallback: true, failure_reason: reason ) end |
Instance Method Details
#allow? ⇒ Boolean
49 50 51 |
# File 'lib/preverus/results.rb', line 49 def allow? recommended_action == "allow" end |
#block? ⇒ Boolean
57 58 59 |
# File 'lib/preverus/results.rb', line 57 def block? ["block", "deny"].include?(recommended_action) end |
#fallback? ⇒ Boolean
61 62 63 |
# File 'lib/preverus/results.rb', line 61 def fallback? @fallback end |
#recommended_action ⇒ Object
45 46 47 |
# File 'lib/preverus/results.rb', line 45 def recommended_action self["recommended_action"] || self["action"] || "review" end |
#review? ⇒ Boolean
53 54 55 |
# File 'lib/preverus/results.rb', line 53 def review? recommended_action == "review" end |