Module: WrAPI::Configuration
- Included in:
- WrAPI
- Defined in:
- lib/wrapi/configuration.rb
Overview
Defines constants and methods related to configuration If configuration is overridden, please add following methods If additional options are added, please overide
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a API
[ :access_token, :token_type, :refresh_token, :token_expires, :client_id, :client_secret, :connection_options, :username, :password, :endpoint, :logger, :format, :page_size, :user_agent, :pagination_class ].freeze
- DEFAULT_CONNECTION_OPTIONS =
By default, don’t set any connection options
{}
- DEFAULT_FORMAT =
Note:
JSON is the only available format at this time
The response format appended to the path and sent in the ‘Accept’ header if none is set
:json
- DEFAULT_PAGE_SIZE =
Note:
default JSON is the only available format at this time
The page size for paged rest responses
500
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set
"Ruby API wrapper #{WrAPI::VERSION}".freeze
- DEFAULT_PAGINATION =
WrAPI::RequestPagination::DefaultPager
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
54 55 56 |
# File 'lib/wrapi/configuration.rb', line 54 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
59 60 61 |
# File 'lib/wrapi/configuration.rb', line 59 def configure yield self end |
#options ⇒ Object
Create a hash of options and their values
64 65 66 67 68 |
# File 'lib/wrapi/configuration.rb', line 64 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Reset all configuration options to defaults
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/wrapi/configuration.rb', line 71 def reset self.access_token = nil self.token_type = nil self.refresh_token = nil self.token_expires = nil self.client_id = nil self.client_secret = nil self.username = nil self.password = nil self.endpoint = nil self.logger = nil self. = DEFAULT_CONNECTION_OPTIONS self.format = DEFAULT_FORMAT self.page_size = DEFAULT_PAGE_SIZE self.user_agent = DEFAULT_USER_AGENT self.pagination_class = DEFAULT_PAGINATION end |