Class: VCSToolkit::Objects::Blob

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

Overview

A blob is a nameless object that contains a snapshot of a file’s data. The file name is stored with the reference to this object (in a Tree object).

The id of the blob is by default its content’s hash.

The content is not serialized by default (in Blob.to_hash) because one might decide that content should be handled differently (or in different format).

Instance Attribute Summary collapse

Attributes inherited from Object

#id, #object_type

Instance Method Summary collapse

Methods inherited from Object

#==, #hash, #named?

Methods included from Serializable

#from_hash, #serialize_on

Methods included from Utils::HashableObject

included

Constructor Details

#initialize(content:, id: nil, **context) ⇒ Blob

Returns a new instance of Blob.



26
27
28
29
30
31
32
# File 'lib/vcs_toolkit/objects/blob.rb', line 26

def initialize(content:, id: nil, **context)
  @content = content

  super id:          id,
        object_type: :blob,
        **context
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



22
23
24
# File 'lib/vcs_toolkit/objects/blob.rb', line 22

def content
  @content
end