Sha256: 3556471d3f23a1968e584aa1f2a9ed6247295a62ba367f97166f5982fdfeae58
Contents?: true
Size: 1.08 KB
Versions: 13
Compression:
Stored size: 1.08 KB
Contents
module Neo4j module Rails module Validations include ActiveModel::Validations def read_attribute_for_validation(key) respond_to?(key) ? send(key) : self[key] end # 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. def save(options={}) perform_validations(options) ? super : false end def valid?(context = nil) context ||= (new_record? ? :create : :update) output = super(context) output_rels = valid_relationships? errors.empty? && output && output_rels end private def perform_validations(options={}) perform_validation = case options when Hash options[:validate] != false end if perform_validation valid?(options.is_a?(Hash) ? options[:context] : nil) else true end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems