Class: Nanoc::RuleDSL::RoutingRule Private

Inherits:
Rule
  • Object
show all
Includes:
Core::ContractsSupport
Defined in:
lib/nanoc/rule_dsl/routing_rule.rb

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.

Instance Attribute Summary collapse

Attributes inherited from Rule

#pattern, #rep_name

Instance Method Summary collapse

Methods inherited from Rule

#applicable_to?, #matches

Constructor Details

#initialize(pattern, rep_name, block, snapshot_name: nil) ⇒ RoutingRule

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 RoutingRule.



11
12
13
14
15
# File 'lib/nanoc/rule_dsl/routing_rule.rb', line 11

def initialize(pattern, rep_name, block, snapshot_name: nil)
  super(pattern, rep_name, block)

  @snapshot_name = snapshot_name
end

Instance Attribute Details

#snapshot_nameObject (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.



8
9
10
# File 'lib/nanoc/rule_dsl/routing_rule.rb', line 8

def snapshot_name
  @snapshot_name
end

Instance Method Details

#apply_to(rep, site:, view_context:) ⇒ Object

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.



21
22
23
24
25
26
27
# File 'lib/nanoc/rule_dsl/routing_rule.rb', line 21

def apply_to(rep, site:, view_context:)
  context = Nanoc::RuleDSL::RoutingRuleContext.new(
    rep:, site:, view_context:,
  )

  context.instance_exec(matches(rep.item.identifier), &@block)
end