Module: Mongoid::Fields::Validators::Macro
Overview
Validates the params passed to the field macro.
Constant Summary collapse
- OPTIONS =
[ :as, :default, :identity, :label, :localize, :fallbacks, :association, :pre_processed, :subtype, :type, :overwrite ]
Instance Method Summary collapse
-
#validate(klass, name, options) ⇒ Object
Validate the field definition.
-
#validate_relation(klass, name, options = {}) ⇒ Object
Validate the relation definition.
Instance Method Details
#validate(klass, name, options) ⇒ Object
Validate the field definition.
34 35 36 37 |
# File 'lib/mongoid/fields/validators/macro.rb', line 34 def validate(klass, name, ) validate_name(klass, name, ) (klass, name, ) end |
#validate_relation(klass, name, options = {}) ⇒ Object
Validate the relation definition.
49 50 51 52 53 54 55 |
# File 'lib/mongoid/fields/validators/macro.rb', line 49 def validate_relation(klass, name, = {}) [name, "#{name}?".to_sym, "#{name}=".to_sym].each do |n| if Mongoid.destructive_fields.include?(n) raise Errors::InvalidRelation.new(klass, n) end end end |