Module: Mongoid::Clients::Validators::Storage

Extended by:
Storage
Included in:
Storage
Defined in:
build/mongoid-7.4/lib/mongoid/clients/validators/storage.rb

Overview

Validates the options passed to :store_in.

Constant Summary collapse

VALID_OPTIONS =

The valid options for storage.

[ :collection, :database, :client ].freeze

Instance Method Summary collapse

Instance Method Details

#validate(klass, options) ⇒ Object

Validate the options provided to :store_in.

Examples:

Validate the options.

Storage.validate(:collection_name)

Parameters:

  • klass (Class)

    The model class.

  • options (Hash, String, Symbol)

    The provided options.



21
22
23
24
# File 'build/mongoid-7.4/lib/mongoid/clients/validators/storage.rb', line 21

def validate(klass, options)
  valid_keys?(options) or raise Errors::InvalidStorageOptions.new(klass, options)
  valid_parent?(klass) or raise Errors::InvalidStorageParent.new(klass)
end