module RapidApi::ActionController::ResourceActions
Public Instance Methods
create()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 31 def create attributes = _member_params query_result = _adapted_model.create attributes, scope if query_result.has_errors? not_processable! _adapted_serializer.serialize_errors(query_result) else render json: _adapted_serializer.serialize(query_result.data), status: response_code_for(:created) end end
destroy()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 56 def destroy id = _adapted_serializer.deserialize_id(params, _params_key) query_result = _adapted_model.destroy id, scope if query_result.found? if query_result.has_errors? not_processable! query_result.errors else head :no_content end else not_found! end end
find_member()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 70 def find_member id = _adapted_serializer.deserialize_id(params, _params_key) query_result = _adapted_model.find id, scope @member = query_result end
index()
click to toggle source
# 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
render_member_ok(member)
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 76 def render_member_ok(member) render json: _adapted_serializer.serialize(member) , status: response_code_for(:ok) end
show()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 21 def show id = _adapted_serializer.deserialize_id(params, _params_key) query_result = _adapted_model.find 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()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 41 def update attributes = _member_params id = _adapted_serializer.deserialize_id(params, _params_key) query_result = _adapted_model.update id, attributes, scope if query_result.found? if query_result.has_errors? not_processable! _adapted_serializer.serialize_errors(query_result) else render json: _adapted_serializer.serialize(query_result.data), status: response_code_for(:ok) end else not_found! end end
Private Instance Methods
_adapted_model()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 82 def _adapted_model self.class.adapted_model end
_adapted_serializer()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 86 def _adapted_serializer self.class.adapted_serializer end
_member_params()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 90 def _member_params _permitted_params_for(_adapted_serializer.deserialize_attributes(params, _params_key)).to_h end
_model()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 94 def _model self.class.model end
_params_key()
click to toggle source
# File lib/rapid_api/action_controller/resource_actions.rb, line 98 def _params_key self.class.params_key end