Class: Gitrb::GitObject

Inherits:
Object
  • Object
show all
Defined in:
lib/gitrb/gitobject.rb

Overview

Base class for blob, tree, commit and tag

Direct Known Subclasses

Blob, Commit, Tag, Tree

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ GitObject

Returns a new instance of GitObject.



7
8
9
10
# File 'lib/gitrb/gitobject.rb', line 7

def initialize(options = {})
  @repository = options[:repository]
  @id = options[:id]
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/gitrb/gitobject.rb', line 5

def id
  @id
end

#repositoryObject

Returns the value of attribute repository.



5
6
7
# File 'lib/gitrb/gitobject.rb', line 5

def repository
  @repository
end

Class Method Details

.factory(type, *args) ⇒ Object

Raises:

  • (NotImplementedError)


26
27
28
29
30
# File 'lib/gitrb/gitobject.rb', line 26

def self.factory(type, *args)
  klass = @types[type]
  raise NotImplementedError, "Object type not supported: #{type}" if !klass
  klass.new(*args)
end

.inherited(subclass) ⇒ Object



22
23
24
# File 'lib/gitrb/gitobject.rb', line 22

def self.inherited(subclass)
  @types[subclass.name[7..-1].downcase] = subclass
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/gitrb/gitobject.rb', line 16

def ==(other)
  self.class === other && id == other.id
end

#git_objectObject



12
13
14
# File 'lib/gitrb/gitobject.rb', line 12

def git_object
  self
end