Class: Droom::Document

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/droom/document.rb

Instance Method Summary collapse

Instance Method Details

#as_search_resultObject



93
94
95
96
97
98
99
100
# File 'app/models/droom/document.rb', line 93

def as_search_result
  {
    :type => 'document',
    :prompt => name,
    :value => name,
    :id => id
  }
end

#as_suggestionObject



84
85
86
87
88
89
90
91
# File 'app/models/droom/document.rb', line 84

def as_suggestion
  {
    :type => 'document',
    :prompt => name,
    :value => name,
    :id => id
  }
end

#attach_to(holder) ⇒ Object



52
53
54
# File 'app/models/droom/document.rb', line 52

def attach_to(holder)
  self.folder = holder.folder
end

#changed_since_creation?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'app/models/droom/document.rb', line 72

def changed_since_creation?
  file_updated_at > created_at
end

#copy_to_dropbox(user) ⇒ Object



102
103
104
# File 'app/models/droom/document.rb', line 102

def copy_to_dropbox(user)
  dropbox_documents.create(:person_id => user.person.id)
end

#create_dropbox_documentsObject



112
113
114
115
116
# File 'app/models/droom/document.rb', line 112

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



56
57
58
# File 'app/models/droom/document.rb', line 56

def detach_from(holder)
  self.folder = nil if self.folder == holder.folder
end

#file_extensionObject



76
77
78
79
80
81
82
# File 'app/models/droom/document.rb', line 76

def file_extension
  if file_file_name
    File.extname(file_file_name).sub(/^\./, '')
  else
    ""
  end
end

#file_ok?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/droom/document.rb', line 60

def file_ok?
  file.exists?
end

#full_pathObject



68
69
70
# File 'app/models/droom/document.rb', line 68

def full_path
  "#{folder.path if folder}/#{file_file_name}"
end

#mark_dropbox_documents_deletedObject



106
107
108
109
110
# File 'app/models/droom/document.rb', line 106

def mark_dropbox_documents_deleted
  dropbox_documents.each do |dd|
    dd.mark_deleted(true)
  end
end

#original_fileObject



64
65
66
# File 'app/models/droom/document.rb', line 64

def original_file
  open(self.file.url)
end

#update_dropbox_documentsObject



118
119
120
121
122
# File 'app/models/droom/document.rb', line 118

def update_dropbox_documents
  dropbox_documents.each do |dd|
    dd.update
  end
end