Class: Nanoc::Core::CompilationContext

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/core/compilation_context.rb

Defined Under Namespace

Classes: FilterNameAndArgs, UndefinedFilterForLayoutError

Constant Summary collapse

C_COMPILED_CONTENT_CACHE =
C::Or[
  Nanoc::Core::CompiledContentCache,
  Nanoc::Core::TextualCompiledContentCache,
  Nanoc::Core::BinaryCompiledContentCache,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(action_provider:, reps:, site:, compiled_content_cache:, compiled_content_store:) ⇒ CompilationContext

Returns a new instance of CompilationContext.



46
47
48
49
50
51
52
# File 'lib/nanoc/core/compilation_context.rb', line 46

def initialize(action_provider:, reps:, site:, compiled_content_cache:, compiled_content_store:)
  @action_provider = action_provider
  @reps = reps
  @site = site
  @compiled_content_cache = compiled_content_cache
  @compiled_content_store = compiled_content_store
end

Instance Attribute Details

#compiled_content_cacheObject (readonly)

Returns the value of attribute compiled_content_cache.



29
30
31
# File 'lib/nanoc/core/compilation_context.rb', line 29

def compiled_content_cache
  @compiled_content_cache
end

#compiled_content_storeObject (readonly)

Returns the value of attribute compiled_content_store.



30
31
32
# File 'lib/nanoc/core/compilation_context.rb', line 30

def compiled_content_store
  @compiled_content_store
end

#repsObject (readonly)

Returns the value of attribute reps.



28
29
30
# File 'lib/nanoc/core/compilation_context.rb', line 28

def reps
  @reps
end

#siteObject (readonly)

Returns the value of attribute site.



27
28
29
# File 'lib/nanoc/core/compilation_context.rb', line 27

def site
  @site
end

Instance Method Details

#filter_name_and_args_for_layout(layout) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/nanoc/core/compilation_context.rb', line 55

def filter_name_and_args_for_layout(layout)
  seq = @action_provider.action_sequence_for(layout)
  if seq.nil? || seq.size != 1 || !seq[0].is_a?(Nanoc::Core::ProcessingActions::Filter)
    raise UndefinedFilterForLayoutError.new(layout)
  end

  FilterNameAndArgs.new(name: seq[0].filter_name, args: seq[0].params)
end