Module: ContextIO::Config
- Included in:
- ContextIO
- Defined in:
- lib/context-io/config.rb
Overview
Defines constants and methods related to configuration
You shouldn’t interact with this module directly, as it’s included in the ContextIO module. Mostly you’ll use the #configure method on ContextIO, see the example on #configure.
Constant Summary collapse
- DEFAULT_ADAPTER =
The HTTP connection adapter that will be used to connect if none is set
:net_http
- DEFAULT_CONNECTION_OPTIONS =
The Faraday connection options if none is set
{}
- DEFAULT_CONSUMER_KEY =
The consumer key if none is set
nil
- DEFAULT_CONSUMER_SECRET =
The consumer secret if none is set
nil
- DEFAULT_PROXY =
The proxy server if none is set
nil
- DEFAULT_USER_AGENT =
The value of sent in the ‘User-Agent’ header if none is set
"context-io ruby gem #{ContextIO::VERSION}"
- VALID_OPTIONS_KEYS =
The configuration options that are settable.
[ :adapter, :connection_options, :consumer_key, :consumer_secret, :proxy, :user_agent ]
Instance Attribute Summary collapse
-
#adapter ⇒ Symbol
The HTTP connection adapter.
-
#connection_options ⇒ Hash
Connection options passed to the Faraday connection object.
-
#consumer_key ⇒ String
The OAuth consumer key received from Context.IO.
-
#consumer_secret ⇒ String
The OAuth consumer secret received from Context.IO.
-
#proxy ⇒ String, URI
The URI to the HTTP proxy to use.
-
#user_agent ⇒ String
The value to be sent in the User-Agent header.
Class Method Summary collapse
-
.extended(base) ⇒ Object
private
Makes sure the default values are always set.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ self
Configure with a block.
-
#reset ⇒ void
Reset the configuration to the default values.
Instance Attribute Details
#adapter ⇒ Symbol
Returns The HTTP connection adapter. Check the Faraday documentation for possible adapters.
42 43 44 |
# File 'lib/context-io/config.rb', line 42 def adapter @adapter end |
#connection_options ⇒ Hash
Returns Connection options passed to the Faraday connection object.
45 46 47 |
# File 'lib/context-io/config.rb', line 45 def @connection_options end |
#consumer_key ⇒ String
Returns The OAuth consumer key received from Context.IO.
48 49 50 |
# File 'lib/context-io/config.rb', line 48 def consumer_key @consumer_key end |
#consumer_secret ⇒ String
Returns The OAuth consumer secret received from Context.IO.
51 52 53 |
# File 'lib/context-io/config.rb', line 51 def consumer_secret @consumer_secret end |
#proxy ⇒ String, URI
Returns The URI to the HTTP proxy to use.
54 55 56 |
# File 'lib/context-io/config.rb', line 54 def proxy @proxy end |
#user_agent ⇒ String
Returns The value to be sent in the User-Agent header. Probably doesn’t need to be changed unless you’re writing a big app, or another library based on this one.
59 60 61 |
# File 'lib/context-io/config.rb', line 59 def user_agent @user_agent end |
Class Method Details
.extended(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Makes sure the default values are always set
64 65 66 |
# File 'lib/context-io/config.rb', line 64 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ self
Configure with a block
79 80 81 82 |
# File 'lib/context-io/config.rb', line 79 def configure yield self self end |
#reset ⇒ void
This method returns an undefined value.
Reset the configuration to the default values
94 95 96 97 98 99 100 101 |
# File 'lib/context-io/config.rb', line 94 def reset self.adapter = DEFAULT_ADAPTER self. = DEFAULT_CONNECTION_OPTIONS self.consumer_key = DEFAULT_CONSUMER_KEY self.consumer_secret = DEFAULT_CONSUMER_SECRET self.proxy = DEFAULT_PROXY self.user_agent = DEFAULT_USER_AGENT end |