lib/mongo_mapper/document.rb in jmonteiro-mongo_mapper-0.1.2 vs lib/mongo_mapper/document.rb in jmonteiro-mongo_mapper-0.1.4

- old
+ new

@@ -336,9 +336,15 @@ def database self.class.database end def save(options={}) + # Support AR style save calls save(false) so ORM agnostic libs can + # successfully call save without validations, regardless of if they + # expect mongo_mapper's style of doing it, or they expect + # ActiveRecord's style of doing it. + options = {:validate => options} if options.is_a?(TrueClass) || options.is_a?(FalseClass) + options.reverse_merge!(:validate => true) perform_validations = options.delete(:validate) !perform_validations || valid? ? create_or_update(options) : false end