lib/builder/action_definitions.rb in sinatra_resource-0.2.0 vs lib/builder/action_definitions.rb in sinatra_resource-0.2.1

- old
+ new

@@ -26,32 +26,40 @@ end def document_for_post(role, model, resource_config, leaf, parent_document, association) check_permission(:create, role, resource_config) check_params(:create, role, resource_config, leaf) + do_callback(:before_create, resource_config, nil) document = create_document!(model) if resource_config[:parent] make_related(parent_document, document, resource_config) end + do_callback(:after_create, resource_config, document) document end def document_for_put(role, model, resource_config, leaf, id, parent_document, association) check_permission(:update, role, resource_config) if resource_config[:parent] check_related?(parent_document, association, id) end check_params(:update, role, resource_config, leaf) - update_document!(model, id) + do_callback(:before_update, resource_config, nil) + document = update_document!(model, id) + do_callback(:after_update, resource_config, document) + document end def document_for_delete(role, model, resource_config, leaf, id, parent_document, association) check_permission(:delete, role, resource_config) if resource_config[:parent] check_related?(parent_document, association, id) end check_params(:delete, role, resource_config, leaf) - delete_document!(model, id) + do_callback(:before_destroy, resource_config, nil) + document = delete_document!(model, id) + do_callback(:after_destroy, resource_config, document) + document end end end