Class: Dragnet::Exporters::Serializers::RepoSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/dragnet/exporters/serializers/repo_serializer.rb

Overview

Serializes a Repo object into a Hash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ RepoSerializer

Returns a new instance of RepoSerializer.

Parameters:



14
15
16
# File 'lib/dragnet/exporters/serializers/repo_serializer.rb', line 14

def initialize(repo)
  @repo = repo
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



11
12
13
# File 'lib/dragnet/exporters/serializers/repo_serializer.rb', line 11

def repo
  @repo
end

Instance Method Details

#serializeHash

Serializes the given Repo object.

Returns:

  • (Hash)

    A Hash representing the given Repo object.



20
21
22
23
24
25
26
27
# File 'lib/dragnet/exporters/serializers/repo_serializer.rb', line 20

def serialize
  {
    path: repo.path,
    sha1: repo.sha1
  }.tap do |hash|
    hash[:files] = serialize_files if repo.files.present?
  end
end