lib/ripple/validations.rb in ripple-1.0.0.beta vs lib/ripple/validations.rb in ripple-1.0.0.beta2

- old
+ new

@@ -34,34 +34,32 @@ validates key, prop.validation_options unless prop.validation_options.blank? end # Instantiates a new document, applies attributes from a block, and saves it # Raises Ripple::DocumentInvalid if the record did not save - def create!(attrs={}, &block) - obj = create(attrs, &block) + def create!(*args, &block) + obj = create(*args, &block) (raise Ripple::DocumentInvalid.new(obj) if obj.new?) || obj end end - module InstanceMethods - # @private - def save(options={:validate => true}) - return false if options[:validate] && !valid? - super() - end - - # Saves the document and raises {DocumentInvalid} exception if - # validations fail. - def save! - (raise Ripple::DocumentInvalid.new(self) unless save) || true - end - - # Sets the passed attributes and saves the document, raising a - # {DocumentInvalid} exception if the validations fail. - def update_attributes!(attrs) - self.attributes = attrs - save! - end + # @private + def save(options={:validate => true}) + return false if options[:validate] && !valid? + super() + end + + # Saves the document and raises {DocumentInvalid} exception if + # validations fail. + def save! + (raise Ripple::DocumentInvalid.new(self) unless save) || true + end + + # Sets the passed attributes and saves the document, raising a + # {DocumentInvalid} exception if the validations fail. + def update_attributes!(attrs) + self.attributes = attrs + save! end end end