Class: GitStore::Blob

Inherits:
Object
  • Object
show all
Defined in:
lib/git_store/blob.rb

Overview

This class stores the raw string data of a blob, but also the deserialized data object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store, id = nil, data = nil) ⇒ Blob

Initialize a Blob



10
11
12
13
14
15
# File 'lib/git_store/blob.rb', line 10

def initialize(store, id = nil, data = nil)
  @store = store
  @id = id || store.id_for('blob', data)
  @data = data
  @mode = "100644"
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/git_store/blob.rb', line 7

def data
  @data
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/git_store/blob.rb', line 7

def id
  @id
end

#modeObject

Returns the value of attribute mode.



7
8
9
# File 'lib/git_store/blob.rb', line 7

def mode
  @mode
end

#objectObject

Returns the value of attribute object.



7
8
9
# File 'lib/git_store/blob.rb', line 7

def object
  @object
end

#storeObject

Returns the value of attribute store.



7
8
9
# File 'lib/git_store/blob.rb', line 7

def store
  @store
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'lib/git_store/blob.rb', line 17

def ==(other)
  Blob === other and id == other.id
end

#dumpObject



21
22
23
# File 'lib/git_store/blob.rb', line 21

def dump
  @data
end

#writeObject

Write the data to the git object store



26
27
28
# File 'lib/git_store/blob.rb', line 26

def write
  @id = store.put(self)
end