Sha256: 211d087265a06c4cd5eae2492383895fbdc9a55079dd9b275fab67581f098a69
Contents?: true
Size: 862 Bytes
Versions: 4
Compression:
Stored size: 862 Bytes
Contents
# frozen_string_literal: true module Nanoc::RuleDSL class RoutingRule < Rule include Nanoc::Core::ContractsSupport contract C::None => C::Maybe[Symbol] attr_reader :snapshot_name contract Nanoc::Core::Pattern, Symbol, Proc, C::KeywordArgs[snapshot_name: C::Optional[Symbol]] => C::Any def initialize(pattern, rep_name, block, snapshot_name: nil) super(pattern, rep_name, block) @snapshot_name = snapshot_name end contract Nanoc::Core::ItemRep, C::KeywordArgs[ site: Nanoc::Int::Site, view_context: Nanoc::ViewContextForPreCompilation, ] => C::Any def apply_to(rep, site:, view_context:) context = Nanoc::RuleDSL::RoutingRuleContext.new( rep: rep, site: site, view_context: view_context, ) context.instance_exec(matches(rep.item.identifier), &@block) end end end
Version data entries
4 entries across 4 versions & 1 rubygems