Skip to content

Latest commit

 

History

History
87 lines (39 loc) · 1.26 KB

Validations.rst

File metadata and controls

87 lines (39 loc) · 1.26 KB

Validations

Constants

Files

Methods

#read_attribute_for_validation

Implements the ActiveModel::Validation hook method.

ruby

def read_attribute_for_validation(key)

respond_to?(key) ? send(key) : self[key]

end

#save

The validation process on save can be skipped by passing false. The regular Model#save method is replaced with this when the validations module is mixed in, which it is by default.

ruby

def save(options = {})

result = perform_validations(options) ? super : false if !result Neo4j::Transaction.current.failure if Neo4j::Transaction.current end result

end

#valid?

ruby

def valid?(context = nil)

context ||= (new_record? ? :create : :update) super(context) errors.empty?

end