Sha256: 70e4515f08a2a8d70c2c8c046929c662438d375500d74e690338cebdef9fb81f
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
module Frisky module Model class Commit < ProxyBase include MongoMapper::Document primary_fetch do |args| c = Commit.find(args[:id]) if args[:id] c ||= Commit.where(args).first if args.any? c or raise NotFound end key :author_id, ObjectId key :message, String key :parent_ids, Array key :repository_id, ObjectId key :stats, Hash key :committer_id, ObjectId 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) 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.no_proxy_author self.repository.save self.committer.save if self.no_proxy_committer 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.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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
frisky_mongo-0.7.7 | lib/frisky-mongo/models/commit.rb |