Sha256: 412c814fe0db6bff960ee813a9768673ddf803b8752e68612a17f73e1ac44d7b
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 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 # updated_at :datetime #
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enju_biblio-0.1.0.pre63 | app/models/resource_export_file.rb |