Class: EventExportFile

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ExportFile, Statesman::Adapters::ActiveRecordQueries
Defined in:
app/models/event_export_file.rb

Instance Method Summary collapse

Instance Method Details

#export!Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/event_export_file.rb', line 28

def export!
  transition_to!(:started)
  tempfile = Tempfile.new(['event_export_file_', '.txt'])
  file = Event.export(format: :txt)
  tempfile.puts(file)
  tempfile.close
  self.event_export = File.new(tempfile.path, "r")
  if save
    send_message
  end
  transition_to!(:completed)
rescue => e
  transition_to!(:failed)
  raise e
end

#state_machineObject



21
22
23
# File 'app/models/event_export_file.rb', line 21

def state_machine
  EventExportFileStateMachine.new(self, transition_class: EventExportFileTransition)
end