class OpenStax::Api::Configuration

Configuration machinery.

To configure OpenStax Api, put the following code in your applications initialization logic (eg. in the config/initializers in a Rails app)

OpenStax::Api.configure do |config|
  config.<parameter name> = <parameter value>
  ...
end

user_class_name is a String containing the name of your User model class.

current_user_method is a String containing the name of your controller method that returns the current user.

routing_error_app is a Rack application that responds to routing errors for the API

validate_cors_origin is a Proc that is called with the reqested origin for CORS requests. The proc should return true/false to indicate the validity of the request’s origin

Attributes

current_user_method[RW]
routing_error_app[RW]
user_class_name[RW]
validate_cors_origin[RW]

Public Class Methods

new() click to toggle source
# File lib/openstax_api.rb, line 44
def initialize
  @user_class_name = 'User'
  @current_user_method = 'current_user'
  @routing_error_app = lambda { |env|
    [404, {"Content-Type" => 'application/json'}, ['']] }
end