Class: Gitrb::GitObject

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

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.



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

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/gitrb/gitobject.rb', line 3

def id
  @id
end

#repositoryObject

Returns the value of attribute repository.



3
4
5
# File 'lib/gitrb/gitobject.rb', line 3

def repository
  @repository
end

Class Method Details

.factory(type, *args) ⇒ Object

Raises:

  • (NotImplementedError)


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

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

.inherited(subclass) ⇒ Object



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

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

Instance Method Details

#objectObject



10
11
12
# File 'lib/gitrb/gitobject.rb', line 10

def object
  self
end