Class: Nanoc3::ItemRepRecorderProxy Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents a fake iem representation that does not actually perform any actual filtering, layouting or snapshotting, but instead keeps track of what would happen if a real item representation would have been used instead. It therefore “records” the actions that happens upon it.

The list of recorded actions is used during compilation to determine whether an item representation needs to be recompiled: if the list of actions is different from the list of actions from the previous compilation run, the item needs to be recompiled; if it is the same, it may not need to be recompiled.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_rep) ⇒ ItemRepRecorderProxy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ItemRepRecorderProxy.

Parameters:

  • item_rep (Nanoc3::ItemRep)

    The item representation that this proxy should behave like



44
45
46
47
# File 'lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb', line 44

def initialize(item_rep)
  @item_rep = item_rep
  @rule_memory = []
end

Instance Attribute Details

#rule_memoryArray (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The list of recorded actions (“rule memory”).

Examples:

The compilation rule and the corresponding rule memory


# rule
compile '/foo/' do
  filter :erb
  filter :myfilter, :arg1 => 'stuff'
  layout 'meh'
end

# memory
[
  [ :filter, :erb, {} ],
  [ :filter, :myfilter, { :arg1 => 'stuff' } ],
  [ :layout, 'meh' ]
]

Returns:

  • (Array)

    The list of recorded actions (“rule memory”)



40
41
42
# File 'lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb', line 40

def rule_memory
  @rule_memory
end

Instance Method Details

#content{}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • ({})


71
72
73
# File 'lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb', line 71

def content
  {}
end

#filter(name, args = {}) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

See Also:

  • Nanoc3::ItemRep#filter


52
53
54
# File 'lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb', line 52

def filter(name, args={})
  @rule_memory << [ :filter, name, args ]
end

#is_proxy?true

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true because this item is already a proxy, and therefore doesn’t need to be wrapped anymore.



82
83
84
# File 'lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb', line 82

def is_proxy?
  true
end

#layout(layout_identifier) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

See Also:

  • Nanoc3::ItemRep#layout


59
60
61
# File 'lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb', line 59

def layout(layout_identifier)
  @rule_memory << [ :layout, layout_identifier ]
end

#snapshot(snapshot_name, params = {}) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



66
67
68
# File 'lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb', line 66

def snapshot(snapshot_name, params={})
  @rule_memory << [ :snapshot, snapshot_name, params ]
end