Class: GenerateRestaurantsCatalogWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/generate_restaurants_catalog_worker.rb

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(file_format = 'csv') ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/workers/generate_restaurants_catalog_worker.rb', line 5

def perform(file_format = 'csv')
  @file_format = file_format

  case @file_format
  when 'xlsx'
    generate_restaurants_catalog_xlsx
  when 'csv'
    generate_restaurants_catalog_csv
  else
    raise ArgumentError, "Unsupported file format: #{@file_format}. Supported formats are 'xlsx' and 'csv'."
  end

  # Store the generated file to Attachment
  store_to_attachment
end