Class: Serega::SeregaPlugins::Formatters::CheckFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/plugins/formatters/formatters.rb

Overview

Validator for formatters defined as config options or directly as attribute :format option

Class Method Summary collapse

Class Method Details

.call(formatter_name, formatter) ⇒ void

This method returns an undefined value.

Check formatter type and parameters

Parameters:

  • formatter_name (Symbol)

    Name of formatter

  • formatter (#call)

    Formatter callable object

Raises:



278
279
280
281
282
283
# File 'lib/serega/plugins/formatters/formatters.rb', line 278

def call(formatter_name, formatter)
  raise Serega::SeregaError, "Option #{formatter_name.inspect} must have callable value" unless formatter.respond_to?(:call)

  signature = SeregaUtils::MethodSignature.call(formatter, pos_limit: 2, keyword_args: [:ctx])
  raise SeregaError, signature_error unless valid_signature?(signature)
end