Class: Twenty::Project
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Twenty::Project
- Includes:
- Mixin::Colorable, Model
- Defined in:
- lib/twenty/server/model/project.rb
Constant Summary
Constants included from Mixin::Colorable
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 Mixin::Colorable
#before_validation, #random_color
Methods included from Model
Instance Method Details
#open_task_count ⇒ Integer
Returns the number of open tasks a project has
37 38 39 40 41 42 |
# File 'lib/twenty/server/model/project.rb', line 37 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.
23 24 25 |
# File 'lib/twenty/server/model/project.rb', line 23 def path super&.sub(Dir.home, "~") end |
#path_exist? ⇒ Boolean
Returns true when #path exists on disk
30 31 32 |
# File 'lib/twenty/server/model/project.rb', line 30 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.
14 15 16 17 18 |
# File 'lib/twenty/server/model/project.rb', line 14 def validate super errors.add(:path, "does not exist on disk") if !path_exist? errors.add(:path, "is not absolute") if !File.absolute_path?(self[:path]) end |