Class: Nanoc::Core::CompilationPhases::Cache

Inherits:
Abstract
  • Object
show all
Includes:
Nanoc::Core::ContractsSupport
Defined in:
lib/nanoc/core/compilation_phases/cache.rb

Overview

Stores the compiled content in the cache once available.

Instance Method Summary collapse

Methods included from Nanoc::Core::ContractsSupport

enabled?, included, setup_once, warn_about_performance

Methods inherited from Abstract

#call, #start, #stop

Constructor Details

#initialize(wrapped:, compiled_content_cache:, compiled_content_repo:) ⇒ Cache

Returns a new instance of Cache.



10
11
12
13
14
15
# File 'lib/nanoc/core/compilation_phases/cache.rb', line 10

def initialize(wrapped:, compiled_content_cache:, compiled_content_repo:)
  super(wrapped:)

  @compiled_content_cache = compiled_content_cache
  @compiled_content_repo = compiled_content_repo
end

Instance Method Details

#run(rep, is_outdated:) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



18
19
20
21
22
23
24
# File 'lib/nanoc/core/compilation_phases/cache.rb', line 18

def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
  return if rep.compiled?

  yield
  @compiled_content_cache[rep] = @compiled_content_repo.get_all(rep)
  rep.compiled = true
end