Class: Nanoc::RuleContext Private
- Inherits:
-
Context
- Object
- Context
- Nanoc::RuleContext
- Defined in:
- lib/nanoc/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)
-
- (void) filter(filter_name, filter_args = {})
private
Filters the current representation (calls ItemRep#filter with the given arguments on the rep).
-
- (RuleContext) initialize(params = {})
constructor
private
A new instance of RuleContext.
-
- (void) layout(layout_identifier)
private
Layouts the current representation (calls ItemRep#layout with the given arguments on the rep).
-
- (void) snapshot(snapshot_name)
private
Creates a snapshot of the current compiled item content.
Methods inherited from Context
Constructor Details
- (RuleContext) initialize(params = {})
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 40 41 42 43 44 |
# File 'lib/nanoc/base/compilation/rule_context.rb', line 27 def initialize(params = {}) rep = params.fetch(:rep) do raise ArgumentError, 'Required :rep option is missing' end compiler = params.fetch(:compiler) do raise ArgumentError, 'Required :compiler option is missing' end super({ rep: rep, item_rep: rep, item: rep.item, site: compiler.site, config: compiler.site.config, items: compiler.site.items, layouts: compiler.site.layouts }) end |
Instance Method Details
- (void) filter(filter_name, filter_args = {})
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).
58 59 60 |
# File 'lib/nanoc/base/compilation/rule_context.rb', line 58 def filter(filter_name, filter_args = {}) rep.filter(filter_name, filter_args) end |
- (void) layout(layout_identifier)
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).
71 72 73 |
# File 'lib/nanoc/base/compilation/rule_context.rb', line 71 def layout(layout_identifier) rep.layout(layout_identifier) end |
- (void) snapshot(snapshot_name)
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.
83 84 85 |
# File 'lib/nanoc/base/compilation/rule_context.rb', line 83 def snapshot(snapshot_name) rep.snapshot(snapshot_name) end |