lib/builder/action_definitions.rb in sinatra_resource-0.4.21 vs lib/builder/action_definitions.rb in sinatra_resource-0.4.22

- old
+ new

@@ -1,7 +1,7 @@ module SinatraResource - + class Builder module ActionDefinitions def document_for_get_one(role, model, resource_config, leaf, id, parent_document, child_assoc) @@ -14,19 +14,19 @@ find_nested_document!(parent_document, child_assoc, model, id) else find_document!(model, id) end end - + def document_count_for_get_many(model, resource_config, parent_document, child_assoc) if resource_config[:parent] count_nested_documents(parent_document, child_assoc, model) else count_documents(model) end end - + def documents_for_get_many(role, model, resource_config, page, items_per_page, leaf, parent_document, child_assoc) check_permission(:list, role, resource_config) check_params(:list, role, resource_config, leaf) documents = if resource_config[:parent] find_nested_documents!(parent_document, child_assoc, model, page, items_per_page) @@ -35,11 +35,11 @@ end documents.select do |doc| authorized?(:read, lookup_role(doc), resource_config) end end - + def document_for_post(role, model, resource_config, leaf, parent_document, child_assoc) check_permission(:create, role, resource_config) check_params(:create, role, resource_config, leaf) do_callback(:before_create, resource_config, nil, parent_document) document = if resource_config[:parent] @@ -51,11 +51,11 @@ make_related(parent_document, document, resource_config) end do_callback(:after_create, resource_config, document, parent_document) document end - + def document_for_put(role, model, resource_config, leaf, id, parent_document, child_assoc) check_permission(:update, role, resource_config) if resource_config[:parent] check_related?(parent_document, child_assoc, id) end @@ -72,11 +72,11 @@ update_document!(model, id) end do_callback(:after_update, resource_config, document, parent_document) document end - + def document_for_delete(role, model, resource_config, leaf, id, parent_document, child_assoc) check_permission(:delete, role, resource_config) if resource_config[:parent] check_related?(parent_document, child_assoc, id) end @@ -95,9 +95,9 @@ do_callback(:after_destroy, resource_config, document, parent_document) document end end - + end - + end