Class: Droom::Document
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Droom::Document
- Defined in:
- app/models/droom/document.rb
Instance Method Summary collapse
- #as_search_result ⇒ Object
- #as_suggestion ⇒ Object
- #attach_to(holder) ⇒ Object
- #changed_since_creation? ⇒ Boolean
- #copy_to_dropbox(user) ⇒ Object
- #create_dropbox_documents ⇒ Object
- #detach_from(holder) ⇒ Object
- #file_extension ⇒ Object
- #file_ok? ⇒ Boolean
- #full_path ⇒ Object
- #mark_dropbox_documents_deleted ⇒ Object
- #original_file ⇒ Object
- #update_dropbox_documents ⇒ Object
Instance Method Details
#as_search_result ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'app/models/droom/document.rb', line 91 def as_search_result { :type => 'document', :prompt => name, :value => name, :id => id } end |
#as_suggestion ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'app/models/droom/document.rb', line 82 def as_suggestion { :type => 'document', :prompt => name, :value => name, :id => id } end |
#attach_to(holder) ⇒ Object
50 51 52 |
# File 'app/models/droom/document.rb', line 50 def attach_to(holder) self.folder = holder.folder end |
#changed_since_creation? ⇒ Boolean
70 71 72 |
# File 'app/models/droom/document.rb', line 70 def changed_since_creation? file_updated_at > created_at end |
#copy_to_dropbox(user) ⇒ Object
100 101 102 |
# File 'app/models/droom/document.rb', line 100 def copy_to_dropbox(user) dropbox_documents.create(:user => user) end |
#create_dropbox_documents ⇒ Object
110 111 112 113 114 |
# File 'app/models/droom/document.rb', line 110 def create_dropbox_documents # after create, in a delayed job # for each user who is syncing our folder, create a dropbox document # that is: everyone who has the sync everything preference or who is associated with the holder of this folder end |
#detach_from(holder) ⇒ Object
54 55 56 |
# File 'app/models/droom/document.rb', line 54 def detach_from(holder) self.folder = nil if self.folder == holder.folder end |
#file_extension ⇒ Object
74 75 76 77 78 79 80 |
# File 'app/models/droom/document.rb', line 74 def file_extension if file_file_name File.extname(file_file_name).sub(/^\./, '') else "" end end |
#file_ok? ⇒ Boolean
58 59 60 |
# File 'app/models/droom/document.rb', line 58 def file_ok? file.exists? end |
#full_path ⇒ Object
66 67 68 |
# File 'app/models/droom/document.rb', line 66 def full_path "#{folder.path if folder}/#{file_file_name}" end |
#mark_dropbox_documents_deleted ⇒ Object
104 105 106 107 108 |
# File 'app/models/droom/document.rb', line 104 def mark_dropbox_documents_deleted dropbox_documents.each do |dd| dd.mark_deleted(true) end end |
#original_file ⇒ Object
62 63 64 |
# File 'app/models/droom/document.rb', line 62 def original_file open(self.file.url) end |
#update_dropbox_documents ⇒ Object
116 117 118 119 120 |
# File 'app/models/droom/document.rb', line 116 def update_dropbox_documents dropbox_documents.each do |dd| dd.update end end |