Module: RapidApi::ActionController::ResourceActions
Defined Under Namespace
Modules: ClassMethods
Constant Summary
Constants included
from Errors
Errors::NotAuthenticatedError, Errors::NotFoundError
Instance Attribute Summary
Attributes included from Scope
#scope
Instance Method Summary
collapse
Methods included from Errors
#not_authenticated!, #not_found!, #not_processable!
#filterable_params
#permitted_params
Instance Method Details
#create ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/rapid_api/action_controller/resource_actions.rb', line 30
def create
query_result = _adapted_model.create _member_params, scope
if query_result.has_errors?
not_processable! query_result.errors
else
render json: _adapted_serializer.serialize(query_result.data), status: response_code_for(:created)
end
end
|
#destroy ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/rapid_api/action_controller/resource_actions.rb', line 52
def destroy
query_result = _adapted_model.destroy params[:id], scope
if query_result.has_errors?
not_processable! query_result.errors
else
head :no_content
end
end
|
#index ⇒ Object
16
17
18
19
|
# File 'lib/rapid_api/action_controller/resource_actions.rb', line 16
def index
query_result = _adapted_model.find_all filterable_params.to_h, scope
render json: _adapted_serializer.serialize_collection(query_result.data), status: response_code_for(:ok)
end
|
#show ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/rapid_api/action_controller/resource_actions.rb', line 21
def show
query_result = _adapted_model.find params[:id], scope
if query_result.found?
render json: _adapted_serializer.serialize(query_result.data) , status: response_code_for(:ok)
else
not_found!
end
end
|
#update ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/rapid_api/action_controller/resource_actions.rb', line 39
def update
query_result = _adapted_model.update params[:id], _member_params, scope
if query_result.found?
if query_result.has_errors?
not_processable! query_result.errors
else
render json: _adapted_serializer.serialize(query_result.data), status: response_code_for(:ok)
end
else
not_found!
end
end
|