Class: SourceMonitor::Scraping::BulkResultPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/source_monitor/scraping/bulk_result_presenter.rb

Overview

Presenter for building flash messages from BulkSourceScraper results Extracts complex message formatting logic from the controller

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result:) ⇒ BulkResultPresenter

Returns a new instance of BulkResultPresenter.



10
11
12
# File 'lib/source_monitor/scraping/bulk_result_presenter.rb', line 10

def initialize(result:)
  @result = result
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/source_monitor/scraping/bulk_result_presenter.rb', line 8

def result
  @result
end

Instance Method Details

#to_flash_payloadObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/source_monitor/scraping/bulk_result_presenter.rb', line 14

def to_flash_payload
  case result.status
  when :success
    build_success_payload
  when :partial
    build_partial_payload
  else
    build_error_payload
  end
end