Module: GitDB::Objects

Defined in:
lib/git-db/objects.rb

Defined Under Namespace

Classes: Base, Blob, Commit, Entry, Tag, Tree

Class Method Summary (collapse)

Class Method Details

+ (Object) new_from_type(type, data)



3
4
5
6
7
8
9
10
11
# File 'lib/git-db/objects.rb', line 3

def self.new_from_type(type, data)
  case type
    when GitDB::OBJ_COMMIT then GitDB::Objects::Commit.new(data)
    when GitDB::OBJ_TREE   then GitDB::Objects::Tree.new(data)
    when GitDB::OBJ_BLOB   then GitDB::Objects::Blob.new(data)
    when GitDB::OBJ_TAG    then GitDB::Objects::Tag.new(data)
    else raise "Unknown object type: #{type}"
  end
end