Class: UserExportFile
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- UserExportFile
- Includes:
- ExportFile, Statesman::Adapters::ActiveRecordQueries
- Defined in:
- app/models/user_export_file.rb
Instance Method Summary collapse
-
#export! ⇒ Object
エクスポートの処理を実行します。.
- #state_machine ⇒ Object
Methods included from ExportFile
Instance Method Details
#export! ⇒ Object
エクスポートの処理を実行します。
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/user_export_file.rb', line 31 def export! transition_to!(:started) tempfile = Tempfile.new(['user_export_file_', '.txt']) file = User.export(format: :txt) tempfile.puts(file) tempfile.close self.user_export = File.new(tempfile.path, 'r') if save end transition_to!(:completed) rescue => e transition_to!(:failed) raise e end |
#state_machine ⇒ Object
23 24 25 |
# File 'app/models/user_export_file.rb', line 23 def state_machine UserExportFileStateMachine.new(self, transition_class: UserExportFileTransition) end |