Class: Twenty::Project
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Twenty::Project
- Includes:
- ColorableMixin, Model
- Defined in:
- lib/twenty/server/model/project.rb
Constant Summary
Constants included from ColorableMixin
Instance Method Summary collapse
-
#open_task_count ⇒ Integer
Returns the number of open tasks a project has.
-
#path ⇒ String
The path to a project.
-
#path_exist? ⇒ Boolean
Returns true when #path exists on disk.
- #validate ⇒ Object private
Methods included from ColorableMixin
#before_validation, #random_color
Methods included from Model
Instance Method Details
#open_task_count ⇒ Integer
Returns the number of open tasks a project has
36 37 38 39 40 41 |
# File 'lib/twenty/server/model/project.rb', line 36 def open_task_count @open_task_count ||= Twenty::Task .where(project_id: id) .where(Sequel.lit("status IN (0,1,2)")) .count end |
#path ⇒ String
Returns The path to a project.
22 23 24 |
# File 'lib/twenty/server/model/project.rb', line 22 def path super&.sub(Dir.home, "~") end |
#path_exist? ⇒ Boolean
Returns true when #path exists on disk
29 30 31 |
# File 'lib/twenty/server/model/project.rb', line 29 def path_exist? File.exist? File.(path) end |
#validate ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 |
# File 'lib/twenty/server/model/project.rb', line 13 def validate super errors.add(:path, "does not exist on disk") if !path_exist? errors.add(:path, "is not absolute") if !File.absolute_path?(path) end |