Class: Serega::Attribute::CheckOptSerializer

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

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:

  • (Error)

    Error that option has invalid value



16
17
18
19
20
21
22
23
24
# File 'lib/serega/validations/attribute/check_opt_serializer.rb', line 16

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

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

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