#-- # Copyright (C) 2008 Dimitrij Denissenko # Please read LICENSE document for more information. #++ class Repository < ActiveRecord::Base class RevisionNotFound < StandardError end class InvalidRevision < StandardError end validates_presence_of :name, :path validates_uniqueness_of :name, :path has_many :changes, :dependent => :destroy has_many :changesets, :dependent => :destroy has_many :projects, :dependent => :nullify class << self def types Repository::Abstract.subclasses.map do |klass| klass.name.demodulize end.sort end def klass(type) "Repository::#{type.to_s.classify}".constantize rescue nil end alias_method :[], :klass end def kind case self[:type] when String then self[:type].dup when Class then self[:type].name.demodulize else nil end end def kind=(value) end end