Class: Nanoc::RuleDSL::RuleContext Private
- Inherits:
-
Int::Context
- Object
- Int::Context
- Nanoc::RuleDSL::RuleContext
- Defined in:
- lib/nanoc/rule_dsl/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.
Instance Method Summary collapse
-
#filter(filter_name, filter_args = {}) ⇒ void
private
Filters the current representation (calls Int::ItemRep#filter with the given arguments on the rep).
-
#initialize(rep:, site:, executor:, view_context:) ⇒ RuleContext
constructor
private
A new instance of RuleContext.
-
#layout(layout_identifier, extra_filter_args = nil) ⇒ void
private
Layouts the current representation (calls Int::ItemRep#layout with the given arguments on the rep).
-
#snapshot(snapshot_name, path: nil) ⇒ void
private
Creates a snapshot of the current compiled item content.
-
#write(path) ⇒ void
private
Creates a snapshot named :last the current compiled item content, with the given path.
Methods inherited from Int::Context
Constructor Details
#initialize(rep:, site:, executor:, view_context:) ⇒ 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.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nanoc/rule_dsl/rule_context.rb', line 12 def initialize(rep:, site:, executor:, view_context:) @_executor = executor super({ item: Nanoc::ItemWithoutRepsView.new(rep.item, view_context), rep: Nanoc::ItemRepView.new(rep, view_context), item_rep: Nanoc::ItemRepView.new(rep, view_context), items: Nanoc::ItemCollectionWithoutRepsView.new(site.items, view_context), layouts: Nanoc::LayoutCollectionView.new(site.layouts, view_context), config: Nanoc::ConfigView.new(site.config, view_context), }) 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 Int::ItemRep#filter with the given arguments on the rep).
37 38 39 |
# File 'lib/nanoc/rule_dsl/rule_context.rb', line 37 def filter(filter_name, filter_args = {}) @_executor.filter(rep.unwrap, filter_name, filter_args) end |
#layout(layout_identifier, extra_filter_args = nil) ⇒ 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 Int::ItemRep#layout with the given arguments on the rep).
50 51 52 |
# File 'lib/nanoc/rule_dsl/rule_context.rb', line 50 def layout(layout_identifier, extra_filter_args = nil) @_executor.layout(rep.unwrap, layout_identifier, extra_filter_args) end |
#snapshot(snapshot_name, path: nil) ⇒ 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 Int::ItemRep#snapshot with the given arguments on the rep.
64 65 66 |
# File 'lib/nanoc/rule_dsl/rule_context.rb', line 64 def snapshot(snapshot_name, path: nil) @_executor.snapshot(rep.unwrap, snapshot_name, path: path) end |
#write(path) ⇒ 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 named :last the current compiled item content, with the given path. This is a convenience method for #snapshot.
76 77 78 |
# File 'lib/nanoc/rule_dsl/rule_context.rb', line 76 def write(path) snapshot(:last, path: path) end |