Skip to content

Commit

Permalink
Git::Object tracks the available types
Browse files Browse the repository at this point in the history
  • Loading branch information
stouset committed May 30, 2008
1 parent 8d81ac3 commit ca2677f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/git/object.rb
Expand Up @@ -48,6 +48,16 @@
class Git::Object
CANONICAL_FORMAT = "%s %d\0%s"

def self.types
@types ||= []
end

def self.inherited(subclass)
# todo: make this not duplicated
types << subclass.name.downcase.sub!(/^.*::/, '').to_sym
types.sort_by {|type| type.to_s }
end

def self.klass(type)
const_get(type.to_s.capitalize)
end
Expand Down

0 comments on commit ca2677f

Please sign in to comment.