Sha256: db5b94b904079800b692ba9e41930ce9beb7328aa8c008f5cc0f0460472796f8
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module TasksManagement class Task < ActiveRecord::Base attr_accessor :owners has_many :sub_tasks, class_name: "Task", foreign_key: "parent_id" belongs_to :parent, class_name: "Task" enum priority: [:high, :medium, :low] enum state: [:pending, :rejected, :started, :finished, :accepted] after_save do unless self.owners.blank? raise TasksManagement::OwnerIdSettedException unless self.owner.blank? self.owners.each do |owner| TasksManagement::Task.create(title: title, description: description, priority: priority, state: state, parent_id: id, owner: owner, requester: requester, end_date: end_date) end end end def start! raise TasksManagement::InvalidTaskStateException unless self.state == 'pending' or self.state == 'rejected' self.started! end def finish! raise TasksManagement::InvalidTaskStateException unless self.state == 'started' self.finished! end def accept! raise TasksManagement::InvalidTaskStateException unless self.state == 'finished' self.accepted! end def reject! raise TasksManagement::InvalidTaskStateException unless self.state == 'finished' self.rejected! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tasks_management-0.1.2 | app/models/tasks_management/task.rb |