Created
January 22, 2010 22:06
-
-
Save dirk/284188 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Project | |
include MongoMapper::Document | |
key :name, String, :required => true | |
key :description, String, :default => '' | |
key :status, Symbol, :required => true, :default => :open | |
key :client_id, ObjectId, :required => true | |
belongs_to :client | |
many :tasks, :dependent => :destroy | |
validates_inclusion_of :status, :within => [:open, :closed] | |
def moments | |
moments = [] | |
self.tasks.each do |task| | |
moments.push *task.moments | |
end | |
return moments.sort {|a, b| b.date <=> a.date } | |
end | |
def incomplete_tasks | |
num = 0 | |
self.tasks.each do |task| | |
if task.status != :complete | |
num += 1 | |
end | |
end | |
return num | |
end | |
class << self | |
def attr_accessible | |
[:name, :description] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment