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:



206
207
208
209
210
211
212
213
214
215
216
# File 'lib/serega/plugins/formatters/formatters.rb', line 206

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