Class: Serega::SeregaPlugins::Formatters::CheckFormatter
- Inherits:
-
Object
- Object
- Serega::SeregaPlugins::Formatters::CheckFormatter
- 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
-
.call(formatter_name, formatter) ⇒ void
Check formatter type and parameters.
Class Method Details
.call(formatter_name, formatter) ⇒ void
This method returns an undefined value.
Check formatter type and parameters
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/serega/plugins/formatters/formatters.rb', line 232 def call(formatter_name, formatter) raise Serega::SeregaError, "Option #{formatter_name.inspect} must have callable value" unless formatter.respond_to?(:call) SeregaValidations::Utils::CheckExtraKeywordArg.call(formatter, "#{formatter_name.inspect} value") params_count = SeregaUtils::ParamsCount.call(formatter, max_count: 2) if params_count > 2 raise SeregaError, "Formatter can have maximum 2 parameters (value to format, context)" end end |