Sha256: bc67e1fad9fa447a19a57976325b2d83b651e70780275007ca691085e8d0e345
Contents?: true
Size: 1.5 KB
Versions: 3
Compression:
Stored size: 1.5 KB
Contents
class ResourceExportFile < ActiveRecord::Base attr_accessible 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
enju_biblio-0.1.0.pre62 | app/models/resource_export_file.rb |
enju_biblio-0.1.0.pre61 | app/models/resource_export_file.rb |
enju_biblio-0.1.0.pre60 | app/models/resource_export_file.rb |