lib/frisky-mongo/models/commit.rb in frisky_mongo-0.7.2 vs lib/frisky-mongo/models/commit.rb in frisky_mongo-0.7.7

- old
+ new

@@ -13,33 +13,35 @@ key :message, String key :parent_ids, Array key :repository_id, ObjectId key :stats, Hash key :committer_id, ObjectId - key :files, Array + key :file_ids, Array key :tree, String key :date, Time key :sha, String belongs_to :author, class_name: 'Frisky::Model::Person' belongs_to :committer, class_name: 'Frisky::Model::Person' belongs_to :repository, class_name: 'Frisky::Model::Repository' many :parents, in: :parent_ids, class_name: 'Frisky::Model::Commit' + many :files, in: :file_ids, class_name: 'Frisky::Model::FileCommit' - proxy_methods author: lambda { Person.find(author_id) } - proxy_methods committer: lambda { Person.find(committer_id) } + proxy_methods author: lambda { Person.find(author_id) or raise NotFound } + proxy_methods committer: lambda { Person.find(committer_id) or raise NotFound } proxy_methods repository: lambda { Repository.find(repository_id) } def save(*args) - self.author.save if self.author - self.repository.save if self.repository - self.committer.save if self.committer + self.author.save if self.no_proxy_author + self.repository.save + self.committer.save if self.no_proxy_committer - self.author_id ||= self.author.id if self.author + self.author_id ||= self.author.id if self.no_proxy_author self.repository_id ||= self.repository.id - self.committer_id ||= self.committer.id if self.committer + self.committer_id ||= self.committer.id if self.no_proxy_committer self.parent_ids |= self.parents.map(&:id) if self.no_proxy_parents + self.file_ids |= self.files.map(&:id) if self.no_proxy_files super(*args) end end end end \ No newline at end of file