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

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

Overview

Validates the options passed to :store_in.

Constant Summary collapse

VALID_OPTIONS =

The valid options for storage.

Since:

  • 3.0.0

[ :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.

Since:

  • 3.0.0



26
27
28
29
# File 'build/mongoid-master/lib/mongoid/clients/validators/storage.rb', line 26

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