Sha256: 9c75b07f8b0900573a14c5d7eae6b7e12a5fc675d28d82a721e4706716b0bb06
Contents?: true
Size: 842 Bytes
Versions: 20
Compression:
Stored size: 842 Bytes
Contents
# encoding: utf-8 module Dynamoid # Provide ActiveModel validations to Dynamoid documents. module Validations extend ActiveSupport::Concern include ActiveModel::Validations include ActiveModel::Validations::Callbacks # Override save to provide validation support. # # @since 0.2.0 def save(options = {}) options.reverse_merge!(:validate => true) return false if options[:validate] and (not valid?) super end # Is this object valid? # # @since 0.2.0 def valid?(context = nil) context ||= (new_record? ? :create : :update) super(context) end # Raise an error unless this object is valid. # # @since 0.2.0 def save! raise Dynamoid::Errors::DocumentNotValid.new(self) unless valid? save(:validate => false) end end end
Version data entries
20 entries across 20 versions & 4 rubygems