Module: DataMapper::Validations::ClassMethods
- Includes:
- AutoValidations, ValidatesAbsence, ValidatesAcceptance, ValidatesConfirmation, ValidatesFormat, ValidatesLength, ValidatesNumericality, ValidatesPresence, ValidatesPrimitiveType, ValidatesUniqueness, ValidatesWithBlock, ValidatesWithMethod, ValidatesWithin
- Defined in:
- lib/dm-validations.rb
Instance Attribute Summary
Attributes included from AutoValidations
Instance Method Summary collapse
- #create(attributes = {}, *args) ⇒ Object
- #inherited(base) ⇒ Object private
-
#validators ⇒ Object
Return the set of contextual validators or create a new one.
Methods included from AutoValidations
#disabled_auto_validations?, generate_for_property, #without_auto_validations
Methods included from ValidatesUniqueness
Methods included from ValidatesWithBlock
Methods included from ValidatesWithMethod
Methods included from ValidatesNumericality
Methods included from ValidatesWithin
Methods included from ValidatesLength
Methods included from ValidatesFormat
Methods included from ValidatesAcceptance
Methods included from ValidatesPrimitiveType
Methods included from ValidatesConfirmation
Methods included from ValidatesAbsence
Methods included from ValidatesPresence
Instance Method Details
#create(attributes = {}, *args) ⇒ Object
128 129 130 131 132 |
# File 'lib/dm-validations.rb', line 128 def create(attributes = {}, *args) resource = new(attributes) resource.save(*args) resource end |
#inherited(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
117 118 119 120 121 122 123 124 125 |
# File 'lib/dm-validations.rb', line 117 def inherited(base) super self.validators.contexts.each do |context, validators| validators.each do |v| = v..merge(:context => context) base.validators.add(v.class, v.field_name, ) end end end |
#validators ⇒ Object
Return the set of contextual validators or create a new one
112 113 114 |
# File 'lib/dm-validations.rb', line 112 def validators @validators ||= ContextualValidators.new(self) end |