Class: ImportableAttachments::Attachment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ImportableAttachments::Attachment
- Includes:
- Paperclip::Glue, Rails::MarkRequirements, SmarterDates
- Defined in:
- app/models/importable_attachments/attachment.rb
Direct Known Subclasses
Constant Summary collapse
- CONTENT_URL =
::Configuration.for('attachments').url
- CONTENT_PATH =
::Configuration.for('attachments').path
Instance Method Summary collapse
-
#io_stream_mime_type ⇒ Object
:call-seq: io_stream_mime_type.
-
#magic_mime_type ⇒ Object
:call-seq: magic_mime_type.
-
#revision_number ⇒ Object
:call-seq: revision_number.
Instance Method Details
#io_stream_mime_type ⇒ Object
:call-seq: io_stream_mime_type
yields the files MIME::Type
105 106 107 108 |
# File 'app/models/importable_attachments/attachment.rb', line 105 def io_stream_mime_type mime = new_record? ? io_stream.content_type : magic_mime_type MIME::Types[mime].first end |
#magic_mime_type ⇒ Object
:call-seq: magic_mime_type
yields a saved attachments mime_type according to libmagic
115 116 117 118 119 |
# File 'app/models/importable_attachments/attachment.rb', line 115 def magic_mime_type return if new_record? return unless File.exists? io_stream.path FileMagic.mime.file(io_stream.path).split(/;\s*/).first end |
#revision_number ⇒ Object
:call-seq: revision_number
yields an integer representing the version-index
NOTE: paper_trail manages version-tracking automatically
88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/models/importable_attachments/attachment.rb', line 88 def revision_number ver = version case when live? then versions.count when ver then ver.index else 0 end end |