lib/sfn/lint/definition.rb in sfn-3.0.28 vs lib/sfn/lint/definition.rb in sfn-3.0.30

- old
+ new

@@ -16,12 +16,12 @@ # # @param expr [String] search expression used for matching # @param provider [String, Symbol] target provider # @param evaluator [Proc] logic used to handle match # @return [self] - def initialize(expr, provider=:aws, evaluator=nil, &block) - if(evaluator && block) + def initialize(expr, provider = :aws, evaluator = nil, &block) + if evaluator && block raise ArgumentError.new 'Only evaluator or block can be provided, not both.' end @provider = Bogo::Utility.snake(provider).to_sym @search_expression = expr @evaluator = evaluator || block @@ -43,15 +43,13 @@ # @param result [Object] result(s) of search expression # @param template [Hash] full template # @return [TrueClass, Array<String>] true if passed. List of string results that failed # @note override this method when subclassing def run(result, template) - unless(evaluator) + unless evaluator raise NotImplementedError.new 'No evaluator has been defined for this definition!' end evaluator.call(result, template) end - end - end end