Class: Serega::SeregaPlugins::ExplicitManyOption::CheckOptMany

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb

Overview

Validator for attribute :many option

Class Method Summary collapse

Class Method Details

.call(opts) ⇒ void

This method returns an undefined value.

Checks attribute :many option must be provided with relations

Parameters:

  • opts (Hash)

    Attribute options

Raises:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb', line 20

def call(opts)
  serializer = opts[:serializer]
  return unless serializer

  many_option_exists = opts.key?(:many)
  return if many_option_exists

  raise SeregaError,
    "Attribute option :many [Boolean] must be provided" \
    " for attributes with :serializer option"
end