Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

make some code easier to read

Christophe Bliard221a006eefb0
diff --git a/app/services/api/parse_resource_params_service.rb b/app/services/api/parse_resource_params_service.rb
index 73888a8931e..4febe096449 100644
--- a/app/services/api/parse_resource_params_service.rb
+++ b/app/services/api/parse_resource_params_service.rb
@@ -36,10 +36,10 @@ module API
self.current_user = user
self.model = model
- self.representer = if !representer && model
- deduce_representer(model)
- elsif representer
+ self.representer = if representer
representer
+ elsif model
+ deduce_representer(model)
else
raise 'Representer not defined'
end
diff --git a/app/services/custom_actions/update_work_package_service.rb b/app/services/custom_actions/update_work_package_service.rb
index 4c6f17c0f1e..392a58bc202 100644
--- a/app/services/custom_actions/update_work_package_service.rb
+++ b/app/services/custom_actions/update_work_package_service.rb
@@ -47,7 +47,7 @@ class CustomActions::UpdateWorkPackageService
result = ::WorkPackages::UpdateService
.new(user: user,
model: work_package)
- .call(**{})
+ .call
block_with_result(result, &block)
end
diff --git a/lib/api/utilities/endpoints/bodied.rb b/lib/api/utilities/endpoints/bodied.rb
index 225b8c2da97..8cdb543c82b 100644
--- a/lib/api/utilities/endpoints/bodied.rb
+++ b/lib/api/utilities/endpoints/bodied.rb
@@ -81,15 +81,16 @@ module API
end
def mount
- update = self
+ endpoint = self
-> do
- update.before_hook&.(request: self)
- params = update.parse(self)
- call = update.process(self, params)
+ request = self # proc is executed in the context of the request
+ endpoint.before_hook&.(request: request)
+ params = endpoint.parse(request)
+ call = endpoint.process(request, params)
- update.render(self, call) do
- status update.success_status
+ endpoint.render(request, call) do
+ status endpoint.success_status
end
end
end
@@ -112,7 +113,7 @@ module API
process_service
.new(**args.compact)
- .with_state(request.instance_exec(**{ model: instance, params: params }, &process_state))
+ .with_state(request.instance_exec(model: instance, params: params, &process_state))
.call(**request.instance_exec(params, &params_modifier))
end