Class: X::RulesRejected
- Inherits:
-
Streaming::Error
- Object
- Error
- Streaming::Error
- X::RulesRejected
- Defined in:
- x-streaming/lib/x/streaming/rules_rejected.rb
Overview
Raised when the API left some of the rules of the filtered stream unchanged, and no block was given for them
The API adds or deletes the rules it can and reports the rest, such as a rule the app already has, 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. 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.
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 did not change.
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.
71 72 73 74 75 76 |
# File 'x-streaming/lib/x/streaming/rules_rejected.rb', line 71 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.
42 43 44 |
# File 'x-streaming/lib/x/streaming/rules_rejected.rb', line 42 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.
53 54 55 |
# File 'x-streaming/lib/x/streaming/rules_rejected.rb', line 53 def deleted_count @deleted_count end |
#problems ⇒ Array<Problem> (readonly)
The problems the API reported of the rules it did not change
31 32 33 |
# File 'x-streaming/lib/x/streaming/rules_rejected.rb', line 31 def problems @problems end |