Module: DataMapper::Validations::ClassMethods

Instance Attribute Summary

Attributes included from AutoValidations

#disable_auto_validations

Instance Method Summary collapse

Methods included from AutoValidations

#disabled_auto_validations?, generate_for_property, #without_auto_validations

Methods included from ValidatesUniqueness

#validates_uniqueness_of

Methods included from ValidatesWithBlock

#validates_with_block

Methods included from ValidatesWithMethod

#validates_with_method

Methods included from ValidatesNumericality

#validates_numericality_of

Methods included from ValidatesWithin

#validates_within

Methods included from ValidatesLength

#validates_length_of

Methods included from ValidatesFormat

#validates_format_of

Methods included from ValidatesAcceptance

#validates_acceptance_of

Methods included from ValidatesPrimitiveType

#validates_primitive_type_of

Methods included from ValidatesConfirmation

#validates_confirmation_of

Methods included from ValidatesAbsence

#validates_absence_of

Methods included from ValidatesPresence

#validates_presence_of

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|
      options = v.options.merge(:context => context)
      base.validators.add(v.class, v.field_name, options)
    end
  end
end

#validatorsObject

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