Class: OpenStax::Api::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax_api.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



41
42
43
44
45
46
# File 'lib/openstax_api.rb', line 41

def initialize      
  @user_class_name = 'User'
  @current_user_method = 'current_user'
  @routing_error_app = lambda { |env|
    [404, {"Content-Type" => 'application/json'}, ['']] }
end

Instance Attribute Details

#current_user_methodObject

Returns the value of attribute current_user_method.



38
39
40
# File 'lib/openstax_api.rb', line 38

def current_user_method
  @current_user_method
end

#routing_error_appObject

Returns the value of attribute routing_error_app.



39
40
41
# File 'lib/openstax_api.rb', line 39

def routing_error_app
  @routing_error_app
end

#user_class_nameObject

Returns the value of attribute user_class_name.



37
38
39
# File 'lib/openstax_api.rb', line 37

def user_class_name
  @user_class_name
end