Module: Dynamoid::Validations
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Validations, ActiveModel::Validations::Callbacks
- Included in:
- Components
- Defined in:
- lib/dynamoid/validations.rb
Overview
Provide ActiveModel validations to Dynamoid documents.
Instance Method Summary (collapse)
-
- (Object) save(options = {})
Override save to provide validation support.
-
- (Object) save!
Raise an error unless this object is valid.
-
- (Boolean) valid?(context = nil)
Is this object valid?.
Instance Method Details
- (Object) save(options = {})
Override save to provide validation support.
14 15 16 17 18 |
# File 'lib/dynamoid/validations.rb', line 14 def save( = {}) .reverse_merge!(:validate => true) return false if [:validate] and (not valid?) super end |
- (Object) save!
Raise an error unless this object is valid.
31 32 33 34 |
# File 'lib/dynamoid/validations.rb', line 31 def save! raise Dynamoid::Errors::DocumentNotValid.new(self) unless valid? save(:validate => false) end |
- (Boolean) valid?(context = nil)
Is this object valid?
23 24 25 26 |
# File 'lib/dynamoid/validations.rb', line 23 def valid?(context = nil) context ||= (new_record? ? :create : :update) super(context) end |