Class: X::RulesRejected
- Inherits:
-
Streams::Error
- Object
- Error
- Streams::Error
- X::RulesRejected
- Defined in:
- x-streams/lib/x/streams/rules_rejected.rb
Overview
Raised when the API rejected some of the rules of the filtered stream, and no block was given for them
The API reports the rules it does not add or delete, such as a rule that is invalid, as errors of a response that otherwise succeeds. StreamingClient#add_rules and StreamingClient#delete_rules yield each of them to a block, and, without one, raise this error rather than drop them, so that a rule that was not added, or a rule a dry run found invalid, is never passed over in silence. A rule the app already has is not one the API rejected, so add_rules raises nothing for it, and it is neither among the #problems nor the rules #added. The rules that were changed stay changed, so the error holds what the method would have returned, the rules add_rules added in #added, or the number of rules delete_rules deleted in #deleted_count, beside the #problems the API reported. The API may add none of the rules it is given alongside one it rejects, and report that one alone, so #added, and not the #problems, says which rules were added.
Instance Attribute Summary collapse
-
#added ⇒ Array<StreamRule>?
readonly
The rules add_rules added.
-
#deleted_count ⇒ Integer?
readonly
The number of rules delete_rules deleted.
-
#problems ⇒ Array<Problem>
readonly
The problems the API reported of the rules it rejected.
Instance Method Summary collapse
-
#initialize(message = nil, problems: [], added: nil, deleted_count: nil) ⇒ RulesRejected
constructor
Initialize a new RulesRejected.
Constructor Details
#initialize(message = nil, problems: [], added: nil, deleted_count: nil) ⇒ RulesRejected
Initialize a new RulesRejected
Public, so that code that rescues a RulesRejected can be tested with one built by hand, as StreamingClient builds one for the problems of a change of the rules, and raised with a message alone, as any exception is. The message is the one given, or else the title and detail of each problem.
77 78 79 80 81 82 |
# File 'x-streams/lib/x/streams/rules_rejected.rb', line 77 def initialize( = nil, problems: [], added: nil, deleted_count: nil) @problems = problems.dup.freeze @added = added.dup.freeze @deleted_count = deleted_count super( || describe(problems)) end |
Instance Attribute Details
#added ⇒ Array<StreamRule>? (readonly)
The rules add_rules added
They are what add_rules would have returned, had it been given a block, so a rule the app already had is not among them: StreamingClient#rules reads it.
48 49 50 |
# File 'x-streams/lib/x/streams/rules_rejected.rb', line 48 def added @added end |
#deleted_count ⇒ Integer? (readonly)
The number of rules delete_rules deleted
It is what delete_rules would have returned, had it been given a block.
59 60 61 |
# File 'x-streams/lib/x/streams/rules_rejected.rb', line 59 def deleted_count @deleted_count end |
#problems ⇒ Array<Problem> (readonly)
The problems the API reported of the rules it rejected
A rule the app already had is not among them, since the API did not reject it.
36 37 38 |
# File 'x-streams/lib/x/streams/rules_rejected.rb', line 36 def problems @problems end |