Class: UffizziCore::ApplicationController
Constant Summary
collapse
- DEFAULT_PAGE =
1
- DEFAULT_PER_PAGE =
20
- RESCUABLE_EXCEPTIONS =
[RuntimeError, TypeError, NameError, ArgumentError, SyntaxError].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
#user_access_module
#init_authorize, #pundit_user
#authenticate_request!, #current_user, #sign_in, #sign_out, #signed_in?
#meta
Class Method Details
.responder ⇒ Object
28
29
30
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 28
def self.responder
UffizziCore::JsonResponder
end
|
Instance Method Details
#page ⇒ Object
50
51
52
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 50
def page
params[:page] || DEFAULT_PAGE
end
|
#per_page ⇒ Object
54
55
56
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 54
def per_page
params[:per_page] || DEFAULT_PER_PAGE
end
|
#policy_context ⇒ Object
24
25
26
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 24
def policy_context
UffizziCore::BaseContext.new(current_user, user_access_module, params)
end
|
#q_param ⇒ Object
46
47
48
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 46
def q_param
params[:q] || ActionController::Parameters.new
end
|
#render_errors(errors) ⇒ Object
40
41
42
43
44
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 40
def render_errors(errors)
json = { errors: errors }
render json: json, status: :unprocessable_entity
end
|
#render_not_found ⇒ Object
32
33
34
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 32
def render_not_found
render json: { errors: { title: ['Resource Not Found'] } }, status: :not_found
end
|
#render_server_error(error) ⇒ Object
36
37
38
|
# File 'app/controllers/uffizzi_core/application_controller.rb', line 36
def render_server_error(error)
render json: { errors: { title: [error] } }, status: :internal_server_error
end
|