lib/nanoc/base/compilation/rule_context.rb in nanoc-3.6.7 vs lib/nanoc/base/compilation/rule_context.rb in nanoc-3.6.8

- old
+ new

@@ -1,5 +1,7 @@ +# encoding: utf-8 + module Nanoc # 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. @@ -22,13 +24,17 @@ # @option params [Nanoc::Compiler] :compiler The compiler that is being # used to compile the site # # @raise [ArgumentError] if the `:rep` or the `:compiler` option is # missing - 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" + 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, @@ -49,10 +55,10 @@ # # @param [Hash] filter_args The filter arguments that should be passed to # the filter's #run method # # @return [void] - def filter(filter_name, filter_args={}) + def filter(filter_name, filter_args = {}) rep.filter(filter_name, filter_args) end # Layouts the current representation (calls {Nanoc::ItemRep#layout} with # the given arguments on the rep).