Class: Story
- Inherits:
-
Object
- Object
- Story
- Includes:
- ActiveModel::MassAssignmentSecurity, Model::MongoDb::Commentable, Model::MongoDb::Customizable, Mongoid::Document, Mongoid::Slug, Mongoid::Timestamps, StateMachines::Story
- Defined in:
- app/models/story.rb
Constant Summary collapse
- PARENT_TYPES =
['project']
Instance Attribute Summary collapse
-
#tasks_file ⇒ Object
Returns the value of attribute tasks_file.
Class Method Summary collapse
Instance Method Summary collapse
- #next_task_for_user(user) ⇒ Object
-
#offeror ⇒ Object
belongs_to (SQL).
- #offeror=(value) ⇒ Object
- #project ⇒ Object
- #project=(value) ⇒ Object
Methods included from Model::MongoDb::Commentable
Instance Attribute Details
#tasks_file ⇒ Object
Returns the value of attribute tasks_file.
31 32 33 |
# File 'app/models/story.rb', line 31 def tasks_file @tasks_file end |
Class Method Details
.for_user(user) ⇒ Object
46 47 48 |
# File 'app/models/story.rb', line 46 def self.for_user(user) raise NotImplementedError end |
Instance Method Details
#next_task_for_user(user) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/models/story.rb', line 57 def next_task_for_user(user) return nil if (users_without_tasks_ids || []).include?(user.id) task = tasks.assigned.not.in(state: ['under_supervision', 'completed']). where(user_id: user.id).first return task if task task = tasks.current.unassigned.where(:unassigned_user_ids.ne => user.id).first if task task.user_id = user.id raise task.errors..join('<br/>') unless task.assign else self.users_without_tasks_ids ||= [] self.users_without_tasks_ids << user.id save end task end |
#offeror ⇒ Object
belongs_to (SQL)
51 |
# File 'app/models/story.rb', line 51 def offeror; offeror_id ? User.find(offeror_id) : nil; end |
#offeror=(value) ⇒ Object
52 |
# File 'app/models/story.rb', line 52 def offeror=(value); self.offeror_id = value.id; end |
#project ⇒ Object
54 |
# File 'app/models/story.rb', line 54 def project; project_id ? Project.find(project_id) : nil; end |
#project=(value) ⇒ Object
55 |
# File 'app/models/story.rb', line 55 def project=(value); @project = value; self.project_id = value.id; end |