Class: Serega::SeregaValidations::Attribute::CheckOptSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/validations/attribute/check_opt_serializer.rb

Overview

Attribute :serializer option validator

Class Method Summary collapse

Class Method Details

.call(opts) ⇒ void

This method returns an undefined value.

Checks attribute :serializer option

Parameters:

  • opts (Hash)

    Attribute options

Raises:

  • (SeregaError)

    SeregaError that option has invalid value



20
21
22
23
24
25
26
27
28
# File 'lib/serega/validations/attribute/check_opt_serializer.rb', line 20

def call(opts)
  return unless opts.key?(:serializer)

  value = opts[:serializer]
  return if valid_serializer?(value)

  raise SeregaError, "Invalid option :serializer => #{value.inspect}." \
    " Can be a Serega subclass, a String or a Proc without arguments"
end