Sha256: 3e1c6d9041d9d5b9563f31db0fac344689b8df7dc2805f61c8db76d74bcf27b1
Contents?: true
Size: 1.16 KB
Versions: 12
Compression:
Stored size: 1.16 KB
Contents
# encoding: utf-8 module Mongoid module Relations # This module contains the validating logic for options passed to relation # macros. module Options extend self # These options are available to all relations. COMMON = [ :class_name, :counter_cache, :extend, :inverse_class_name, :inverse_of, :name, :relation, :validate ] # Determine if the provided options are valid for the relation. # # @example Check the options. # Options.validate!(:name => :comments) # # @param [ Hash ] options The options to check. # # @raise [ ArgumentError ] If the options are invalid. # # @return [ true, false ] If the options are valid. # # @since 2.1.0 def validate!(options) valid_options = options[:relation].valid_options.concat(COMMON) options.keys.each do |key| if !valid_options.include?(key) raise Errors::InvalidOptions.new( options[:name], key, valid_options ) end end end end end end
Version data entries
12 entries across 12 versions & 4 rubygems