Class: Serega::SeregaPlugins::Formatters::CheckOptFormat

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

Overview

Validator for attribute :format option

Class Method Summary collapse

Class Method Details

.call(opts, serializer_class) ⇒ void

This method returns an undefined value.

Checks attribute :format option must be registered or valid callable with maximum 2 args

Parameters:

  • opts (value)

    Attribute options

Raises:



243
244
245
246
247
248
249
250
251
252
253
# File 'lib/serega/plugins/formatters/formatters.rb', line 243

def call(opts, serializer_class)
  return unless opts.key?(:format)

  formatter = opts[:format]

  if formatter.is_a?(Symbol)
    check_formatter_defined(serializer_class, formatter)
  else
    CheckFormatter.call(:format, formatter)
  end
end