Class: Serega::SeregaPlugins::Metadata::MetaAttribute::CheckOpts

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/plugins/metadata/validations/check_opts.rb

Overview

Validator for meta_attribute options

Class Method Summary collapse

Class Method Details

.call(opts, attribute_keys) ⇒ void

This method returns an undefined value.

Validates attribute options Checks used options are allowed and then checks options values.

Parameters:

  • opts (Hash)

    Attribute options

  • attribute_keys (Array<Symbol>)

    Allowed options keys

Raises:



23
24
25
26
27
28
29
30
31
# File 'lib/serega/plugins/metadata/validations/check_opts.rb', line 23

def call(opts, attribute_keys)
  opts.each_key do |key|
    next if attribute_keys.include?(key.to_sym)

    raise SeregaError, "Invalid option #{key.inspect}. Allowed options are: #{attribute_keys.map(&:inspect).join(", ")}"
  end

  check_each_opt(opts)
end