Class: Packwerk::Cache::CacheContents

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packwerk/cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deserialize(serialized_cache_contents) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/packwerk/cache.rb', line 20

def deserialize(serialized_cache_contents)
  cache_contents_json = JSON.parse(serialized_cache_contents)
  unresolved_references = cache_contents_json["unresolved_references"].map do |json|
    UnresolvedReference.new(
      constant_name: json["constant_name"],
      namespace_path: json["namespace_path"],
      relative_path: json["relative_path"],
      source_location: Node::Location.new(json["source_location"]["line"], json["source_location"]["column"],)
    )
  end

  CacheContents.new(
    file_contents_digest: cache_contents_json["file_contents_digest"],
    unresolved_references: unresolved_references,
  )
end

Instance Method Details

#serializeObject



39
40
41
# File 'lib/packwerk/cache.rb', line 39

def serialize
  to_json
end