Module: GithubBot::Response

Included in:
ApplicationController
Defined in:
app/controllers/github_bot/concerns/response.rb

Overview

Public: A helper to the controllers for assisting in providing json responses

Instance Method Summary collapse

Instance Method Details

#json_access_denied(**args) ⇒ Object

Public: Returns a json response indicating a 403



21
22
23
# File 'app/controllers/github_bot/concerns/response.rb', line 21

def json_access_denied(**args)
  { errors: 'access denied' }.merge(args)
end

#json_not_found(params) ⇒ Object

Public: Returns a json response indicating a 404



12
13
14
15
16
17
18
# File 'app/controllers/github_bot/concerns/response.rb', line 12

def json_not_found(params)
  {
    errors: {
      message: "Not found with parameter #{params}"
    }
  }
end

#json_response(object, status = :ok) ⇒ Object

Public: Renders a json response



7
8
9
# File 'app/controllers/github_bot/concerns/response.rb', line 7

def json_response(object, status = :ok)
  render json: object, status: status
end