module Dynamoid::Validations
Provide ActiveModel validations to Dynamoid
documents.
Public Instance Methods
save(options = {})
click to toggle source
Override save to provide validation support.
@since 0.2.0
Calls superclass method
# File lib/dynamoid/validations.rb, line 14 def save(options = {}) options.reverse_merge!(:validate => true) return false if options[:validate] and (not valid?) super end
save!()
click to toggle source
Raise an error unless this object is valid.
@since 0.2.0
# File lib/dynamoid/validations.rb, line 31 def save! raise Dynamoid::Errors::DocumentNotValid.new(self) unless valid? save(:validate => false) end
valid?(context = nil)
click to toggle source
Is this object valid?
@since 0.2.0
Calls superclass method
# File lib/dynamoid/validations.rb, line 23 def valid?(context = nil) context ||= (new_record? ? :create : :update) super(context) end