Module: Mongoid::Validations
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Validations
- Included in:
- Components
- Defined in:
- lib/mongoid/validations.rb,
lib/mongoid/validations/associated.rb,
lib/mongoid/validations/referenced.rb,
lib/mongoid/validations/uniqueness.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods Classes: AssociatedValidator, ReferencedValidator, UniquenessValidator
Instance Attribute Summary collapse
-
#validated ⇒ Object
Returns the value of attribute validated.
Instance Method Summary collapse
-
#read_attribute_for_validation(attr) ⇒ Object
Overrides the default ActiveModel behaviour since we need to handle validations of relations slightly different than just calling the getter.
-
#valid?(context = nil) ⇒ true, false
Determine if the document is valid.
-
#validated? ⇒ true, false
Used to prevent infinite loops in associated validations.
Instance Attribute Details
#validated ⇒ Object
Returns the value of attribute validated.
14 15 16 |
# File 'lib/mongoid/validations.rb', line 14 def validated @validated end |
Instance Method Details
#read_attribute_for_validation(attr) ⇒ Object
Overrides the default ActiveModel behaviour since we need to handle validations of relations slightly different than just calling the getter.
28 29 30 31 32 33 34 |
# File 'lib/mongoid/validations.rb', line 28 def read_attribute_for_validation(attr) if relations[attr.to_s] send(attr, false, :eager => true) else send(attr) end end |
#valid?(context = nil) ⇒ true, false
Determine if the document is valid.
49 50 51 |
# File 'lib/mongoid/validations.rb', line 49 def valid?(context = nil) super context ? context : (new? ? :create : :update) end |
#validated? ⇒ true, false
Used to prevent infinite loops in associated validations.
61 62 63 |
# File 'lib/mongoid/validations.rb', line 61 def validated? !!@validated end |