Module: Ripple::Validations::InstanceMethods

Defined in:
lib/ripple/validations.rb

Instance Method Summary collapse

Instance Method Details

#save(options = {:validate => true}) ⇒ Object



61
62
63
64
# File 'lib/ripple/validations.rb', line 61

def save(options={:validate => true})
  return false if options[:validate] && !valid?
  super()
end

#save!Object

Saves the document and raises DocumentInvalid exception if validations fail.



68
69
70
# File 'lib/ripple/validations.rb', line 68

def save!
  (raise Ripple::DocumentInvalid.new(self) unless save) || true
end

#update_attributes!(attrs) ⇒ Object

Sets the passed attributes and saves the document, raising a DocumentInvalid exception if the validations fail.



74
75
76
77
# File 'lib/ripple/validations.rb', line 74

def update_attributes!(attrs)
  self.attributes = attrs
  save!
end