1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-12 23:09:03 +01:00
fab-manager/app/workers/availabilities_export_worker.rb
2017-03-02 12:34:28 +01:00

28 lines
735 B
Ruby

class AvailabilitiesExportWorker
include Sidekiq::Worker
def perform(export_id)
export = Export.find(export_id)
unless export.user.is_admin?
raise SecurityError, 'Not allowed to export'
end
unless export.category == 'availabilities'
raise KeyError, 'Wrong worker called'
end
service = AvailabilitiesExportService.new
method_name = "export_#{export.export_type}"
if %w(index).include?(export.export_type) and service.respond_to?(method_name)
service.public_send(method_name, export)
NotificationCenter.call type: :notify_admin_export_complete,
receiver: export.user,
attached_object: export
end
end
end