Class: Html2rss::FeedPipeline::AutoFallback::AttemptState
- Inherits:
-
Object
- Object
- Html2rss::FeedPipeline::AutoFallback::AttemptState
- Defined in:
- lib/html2rss/feed_pipeline/auto_fallback.rb
Overview
Mutable run state for one auto-fallback chain: attempts plus selected result.
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize ⇒ AttemptState
constructor
A new instance of AttemptState.
- #record_error(strategy:, error:) ⇒ void
- #record_items(strategy:, items_count:, transport_meta: nil) ⇒ void
- #succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:) ⇒ void
-
#succeeded? ⇒ Boolean
True when a strategy already yielded items.
Constructor Details
#initialize ⇒ AttemptState
Returns a new instance of AttemptState.
31 32 33 34 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 31 def initialize @attempts = [] @result = nil end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
29 30 31 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 29 def attempts @attempts end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
29 30 31 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 29 def result @result end |
Instance Method Details
#record_error(strategy:, error:) ⇒ void
This method returns an undefined value.
42 43 44 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 42 def record_error(strategy:, error:) @attempts << { strategy:, items_count: nil, error_class: error.class.name } end |
#record_items(strategy:, items_count:, transport_meta: nil) ⇒ void
This method returns an undefined value.
50 51 52 53 54 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 50 def record_items(strategy:, items_count:, transport_meta: nil) attempt = { strategy:, items_count:, error_class: nil } attempt[:transport_meta] = if && !.empty? @attempts << attempt end |
#succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:) ⇒ void
This method returns an undefined value.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 62 def succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:) @result = PipelineOutcome.new( response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, strategy_attempts: attempts ) end |
#succeeded? ⇒ Boolean
Returns true when a strategy already yielded items.
37 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 37 def succeeded? = !result.nil? |