Class: Services::ServicesController
Constant Summary
ApplicationController::MAX_LIST_LENGTH
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#service ⇒ Object
Returns the value of attribute service.
4
5
6
|
# File 'app/controllers/services/services_controller.rb', line 4
def service
@service
end
|
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'app/controllers/services/services_controller.rb', line 17
def create
svc = CreateServiceContext.call(safe_params)
if svc.errors.empty?
render json: { id: svc.id }
else
render json: { validation_error: svc.errors.full_messages }, status: 403
end
end
|
#index ⇒ Object
10
11
12
|
# File 'app/controllers/services/services_controller.rb', line 10
def index
@services = Service.limit(MAX_LIST_LENGTH)
end
|
#invoke ⇒ Object
35
36
37
38
39
40
41
|
# File 'app/controllers/services/services_controller.rb', line 35
def invoke
InvokeServiceContext.call(service)
render json: { message: "Service '#{service.name}' invoked in the background" }
rescue Exception => ex
render json: { error: "Error invoking Service '#{service.name}': #{ex.message}" }
end
|
#show ⇒ Object
14
15
|
# File 'app/controllers/services/services_controller.rb', line 14
def show
end
|
#update ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'app/controllers/services/services_controller.rb', line 26
def update
UpdateServiceContext.call(service, safe_params)
if service.errors.empty?
render json: { id: service.id }
else
render json: { validation_error: service.errors.full_messages }, status: 403
end
end
|