Class: OpenStax::Api::V1::ApiController

Inherits:
ActionController::Base
  • Object
show all
Includes:
Apipie, Roar, Roar::Rails::ControllerAdditions
Defined in:
app/controllers/openstax/api/v1/api_controller.rb

Instance Method Summary collapse

Methods included from Apipie

included

Methods included from Roar

#render_api_errors, #standard_create, #standard_destroy, #standard_index, #standard_nested_create, #standard_read, #standard_search, #standard_sort, #standard_update

Instance Method Details

#consume!(model, options = {}) ⇒ Object



37
38
39
40
41
# File 'app/controllers/openstax/api/v1/api_controller.rb', line 37

def consume!(model, options = {})
  # Don't error out if no CONTENT_TYPE header
  request.env['CONTENT_TYPE'] ||= 'application/json'
  super
end

#current_api_userObject

Always return an ApiUser



24
25
26
27
# File 'app/controllers/openstax/api/v1/api_controller.rb', line 24

def current_api_user
  @current_api_user ||= ApiUser.new(doorkeeper_token,
                                    lambda { current_session_user })
end

#current_applicationObject



29
30
31
# File 'app/controllers/openstax/api/v1/api_controller.rb', line 29

def current_application
  current_api_user.application
end

#current_human_userObject



33
34
35
# File 'app/controllers/openstax/api/v1/api_controller.rb', line 33

def current_human_user
  current_api_user.human_user
end