Class: Task
- Inherits:
-
Object
- Object
- Task
- Includes:
- ActiveModel::MassAssignmentSecurity, Model::MongoDb::Commentable, Model::MongoDb::Customizable, Mongoid::Document, Mongoid::Slug, Mongoid::Timestamps, StateMachines::Task
- Defined in:
- app/models/task.rb
Constant Summary collapse
- PARENT_TYPES =
track_history on: [:user_id, :name, :text, :state]
['story']
Instance Method Summary collapse
- #after_transition(transition) ⇒ Object
- #author ⇒ Object
- #author=(value) ⇒ Object
- #before_transition(transition) ⇒ Object
-
#offeror ⇒ Object
belongs_to (SQL).
- #offeror=(value) ⇒ Object
- #result_class ⇒ Object
- #to_json ⇒ Object
- #user ⇒ Object
- #user=(value) ⇒ Object
- #with_result? ⇒ Boolean
Methods included from Model::MongoDb::Commentable
Instance Method Details
#after_transition(transition) ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'app/models/task.rb', line 90 def after_transition(transition) case transition.event when :follow_up self.story.activate if self.story.completed? when :complete if self.story.tasks.complete.count == self.story.tasks.count self.story.complete end end end |
#author ⇒ Object
55 |
# File 'app/models/task.rb', line 55 def ; ? User.find() : nil; end |
#author=(value) ⇒ Object
56 |
# File 'app/models/task.rb', line 56 def (value); self. = value.id; end |
#before_transition(transition) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/task.rb', line 70 def before_transition(transition) self.event = transition.event.to_s self.state_before = transition.from case transition.event when :assign self. = self.user_id when :cancel self.unassigned_user_ids ||= [] self.unassigned_user_ids << self.user_id self.user_id = nil self. = nil self.result.text = nil if self.result when :review self.user_id = self.offeror_id when :follow_up self.user_id = self. end end |
#offeror ⇒ Object
belongs_to (SQL)
49 |
# File 'app/models/task.rb', line 49 def offeror; offeror_id ? User.find(offeror_id) : nil; end |
#offeror=(value) ⇒ Object
50 |
# File 'app/models/task.rb', line 50 def offeror=(value); self.offeror_id = value.id; end |
#result_class ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/models/task.rb', line 58 def result_class if product_id.present? "#{product.class.name}::Result".constantize rescue Result else Result end end |
#to_json ⇒ Object
101 102 103 104 105 106 107 |
# File 'app/models/task.rb', line 101 def to_json record = { id: id.to_s, offeror_id: offeror_id, user_id: user_id, author_id: , name: name, text: text, state: state } record[:result] = result.to_json if result.present? record end |
#user ⇒ Object
52 |
# File 'app/models/task.rb', line 52 def user; user_id ? User.find(user_id) : nil; end |
#user=(value) ⇒ Object
53 |
# File 'app/models/task.rb', line 53 def user=(value); self.user_id = value.id; end |
#with_result? ⇒ Boolean
66 67 68 |
# File 'app/models/task.rb', line 66 def with_result? true end |