Sha256: 010c3a3c817d38235e0ad21e2882fdb5d30b80632cf39e4250a61086c60f1ad7
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
class ResourceExportFile < ActiveRecord::Base include Statesman::Adapters::ActiveRecordModel include ExportFile enju_export_file_model has_attached_file :resource_export validates_attachment_content_type :resource_export, :content_type => /\Atext\/plain\Z/ has_many :resource_export_file_transitions def state_machine ResourceExportFileStateMachine.new(self, transition_class: ResourceExportFileTransition) end delegate :can_transition_to?, :transition_to!, :transition_to, :current_state, to: :state_machine def export! transition_to!(:started) tempfile = Tempfile.new(['resource_export_file_', '.txt']) file = Manifestation.export(format: :txt) tempfile.puts(file) tempfile.close self.resource_export = File.new(tempfile.path, "r") if save send_message end transition_to!(:completed) rescue => e transition_to!(:failed) raise e end private def self.transition_class ResourceExportFileTransition end end # == Schema Information # # Table name: resource_export_files # # id :integer not null, primary key # user_id :integer # resource_export_file_name :string(255) # resource_export_content_type :string(255) # resource_export_file_size :integer # resource_export_updated_at :datetime # executed_at :datetime # created_at :datetime not null # updated_at :datetime not null #
Version data entries
4 entries across 4 versions & 1 rubygems