Namespace

Included Modules

Class Index [+]

Quicksearch

DataMapper::Validations

Public Class Methods

included(model) click to toggle source
    # File lib/dm-validations.rb, line 30
30:     def self.included(model)
31:       model.extend ClassMethods
32:     end

Public Instance Methods

errors() click to toggle source

Return the ValidationErrors

@api public

    # File lib/dm-validations.rb, line 61
61:     def errors
62:       @errors ||= ValidationErrors.new(self)
63:     end
save(context = default_validation_context) click to toggle source

Ensures the object is valid for the context provided, and otherwise throws :halt and returns false.

@api public

    # File lib/dm-validations.rb, line 38
38:     def save(context = default_validation_context)
39:       model.validators.assert_valid(context)
40:       Validations::Context.in_context(context) { super() }
41:     end
save_self(*) click to toggle source

@api private

    # File lib/dm-validations.rb, line 50
50:     def save_self(*)
51:       if Validations::Context.any? && !valid?(model.validators.current_context)
52:         false
53:       else
54:         super
55:       end
56:     end
update(attributes = {}, context = default_validation_context) click to toggle source

@api public

    # File lib/dm-validations.rb, line 44
44:     def update(attributes = {}, context = default_validation_context)
45:       model.validators.assert_valid(context)
46:       Validations::Context.in_context(context) { super(attributes) }
47:     end
valid?(context = :default) click to toggle source

Check if a resource is valid in a given context

@api public

    # File lib/dm-validations.rb, line 84
84:     def valid?(context = :default)
85:       model = respond_to?(:model) ? self.model : self.class
86:       model.validators.execute(context, self)
87:     end
valid_for_default?() click to toggle source

Alias for valid?(:default)

TODO: deprecate

    # File lib/dm-validations.rb, line 77
77:     def valid_for_default?
78:       valid?(:default)
79:     end
validatable?() click to toggle source

Mark this resource as validatable. When we validate associations of a resource we can check if they respond to validatable? before trying to recursively validate them

@api semipublic

    # File lib/dm-validations.rb, line 70
70:     def validatable?
71:       true
72:     end
validation_property_value(name) click to toggle source

@api semipublic

    # File lib/dm-validations.rb, line 90
90:     def validation_property_value(name)
91:       __send__(name) if respond_to?(name, true)
92:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.