README.md in langalex-couch_potato-0.2.2 vs README.md in langalex-couch_potato-0.2.3
- old
+ new
@@ -219,13 +219,15 @@
class User
include CouchPotato::Persistence
before_create :do_something_before_create
- after_update :do_something_else
+ before_update {|user, db| user.do_something_on_update}
end
-This will call the method do_something_before_create before creating an object and do_something_else after updating one. Supported callbacks are: :before_validation_on_create, :before_validation_on_update, :before_validation_on_save, :before_create, :after_create, :before_update, :after_update, :before_save, :after_save, :before_destroy, :after_destroy. You can also pass a Proc instead of a method name.
+This will call the method do_something_before_create before creating an object and run the given lambda before updating one. Lambda callbacks get passed the model as their first argument. Optionally if a lambda declares two arguments it also gets passed the database object. This is useful for creating other objects or querying views. Method callbacks don't receive any arguments by default but will get passed the database if they declare an argument.
+
+Supported callbacks are: :before_validation_on_create, :before_validation_on_update, :before_validation_on_save, :before_create, :after_create, :before_update, :after_update, :before_save, :after_save, :before_destroy, :after_destroy.
#### Testing
To make testing easier and faster database logic has been put into its own class, which you can replace and stub out in whatever way you want: