Class: Nanoc3::RuleContext Private
- Defined in:
- lib/nanoc3/base/compilation/rule_context.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.
Provides a context in which compilation and routing rules can be executed. It provides access to the item representation that is being compiled or routed.
The following variables will be available in this rules context:
Instance Method Summary collapse
-
#filter(filter_name, filter_args = {}) ⇒ void
private
Filters the current representation (calls ItemRep#filter with the given arguments on the rep).
-
#initialize(params = {}) ⇒ RuleContext
constructor
private
A new instance of RuleContext.
-
#layout(layout_identifier) ⇒ void
private
Layouts the current representation (calls ItemRep#layout with the given arguments on the rep).
-
#snapshot(snapshot_name) ⇒ void
private
Creates a snapshot of the current compiled item content.
Methods inherited from Context
Constructor Details
#initialize(params = {}) ⇒ RuleContext
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 RuleContext.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nanoc3/base/compilation/rule_context.rb', line 27 def initialize(params={}) rep = params[:rep] or raise ArgumentError, "Required :rep option is missing" compiler = params[:compiler] or raise ArgumentError, "Required :compiler option is missing" super({ :rep => rep, :item => rep.item, :site => compiler.site, :config => compiler.site.config, :items => compiler.site.items, :layouts => compiler.site.layouts }) end |
Instance Method Details
#filter(filter_name, filter_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.
Filters the current representation (calls ItemRep#filter with the given arguments on the rep).
53 54 55 |
# File 'lib/nanoc3/base/compilation/rule_context.rb', line 53 def filter(filter_name, filter_args={}) rep.filter(filter_name, filter_args) 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.
Layouts the current representation (calls ItemRep#layout with the given arguments on the rep).
66 67 68 |
# File 'lib/nanoc3/base/compilation/rule_context.rb', line 66 def layout(layout_identifier) rep.layout(layout_identifier) end |
#snapshot(snapshot_name) ⇒ 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.
Creates a snapshot of the current compiled item content. Calls ItemRep#snapshot with the given arguments on the rep.
78 79 80 |
# File 'lib/nanoc3/base/compilation/rule_context.rb', line 78 def snapshot(snapshot_name) rep.snapshot(snapshot_name) end |