Class: Core::Models::Files::Document
- Inherits:
-
Object
- Object
- Core::Models::Files::Document
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/core/models/files/document.rb
Overview
a document is an uploaded file in the S3 clone application.
Instance Attribute Summary collapse
-
#creator ⇒ Core::Models::Account
The account of the person that uploaded the file.
-
#folder ⇒ String
The folder in which the file is stored in the S3 clone.
-
#mime_type ⇒ String
The MIME type of the file.
-
#name ⇒ String
The filename the user entered when uploading the file.
-
#permissions ⇒ Array<Core::Models::Files::Permission>
The permissions granted to access this file.
-
#size ⇒ String
The size, in bytes, of the uploaded file.
Instance Method Summary collapse
Instance Attribute Details
#creator ⇒ Core::Models::Account
Returns the account of the person that uploaded the file.
30 |
# File 'lib/core/models/files/document.rb', line 30 belongs_to :creator, class_name: 'Core::Models::Account', inverse_of: :files |
#folder ⇒ String
Returns the folder in which the file is stored in the S3 clone.
22 |
# File 'lib/core/models/files/document.rb', line 22 field :folder, type: String, default: '/' |
#mime_type ⇒ String
Returns the MIME type of the file. this MAY not correspond to the real MIME type of the uploaded file, this is just an indication.
26 |
# File 'lib/core/models/files/document.rb', line 26 field :mime_type, type: String |
#name ⇒ String
Returns the filename the user entered when uploading the file.
14 |
# File 'lib/core/models/files/document.rb', line 14 field :name, type: String |
#permissions ⇒ Array<Core::Models::Files::Permission>
Returns the permissions granted to access this file.
34 |
# File 'lib/core/models/files/document.rb', line 34 has_many :permissions, class_name: 'Core::Models::Files::Permission', inverse_of: :file |
#size ⇒ String
Returns the size, in bytes, of the uploaded file.
19 |
# File 'lib/core/models/files/document.rb', line 19 field :size, type: Integer, default: 0 |
Instance Method Details
#filename_unicity ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/core/models/files/document.rb', line 42 def filename_unicity existing = Core::Models::Files::Document.where( name: name, folder: folder, extension: extension, :id.ne => id ) errors.add(:name, 'uniq') unless existing.first.nil? end |