Module: Flattr::Config
- Included in:
- Flattr
- Defined in:
- lib/flattr/config.rb
Overview
Defines constants and methods related to configuration
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_CLIENT_ID =
The client key if none is set
nil
- DEFAULT_CLIENT_SECRET =
The consumer secret if none is set
nil
- DEFAULT_ENDPOINT =
The endpoint that will be used to connect if none is set
'https://api.flattr.com'
- DEFAULT_AUTHORIZE_ENDPOINT =
'https://flattr.com/oauth/authorize'
- DEFAULT_TOKEN_ENDPOINT =
'https://flattr.com/oauth/token'
- DEFAULT_GATEWAY =
The gateway server if none is set
nil
- DEFAULT_ACCESS_TOKEN =
The access token if none is set
nil
- DEFAULT_PROXY =
The proxy server if none is set
nil
- DEFAULT_USER_AGENT =
The value sent in the ‘User-Agent’ header if none is set
"Flattr Ruby Gem #{Flattr::Version}"
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a Flattr::Client
[ :adapter, :connection_options, :client_id, :client_secret, :endpoint, :authorize_endpoint, :token_endpoint, :gateway, :access_token, :proxy, :user_agent, ]
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
56 57 58 |
# File 'lib/flattr/config.rb', line 56 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
61 62 63 64 |
# File 'lib/flattr/config.rb', line 61 def configure yield self self end |
#options ⇒ Object
Create a hash of options and their values
67 68 69 70 71 |
# File 'lib/flattr/config.rb', line 67 def = {} VALID_OPTIONS_KEYS.each{|k| [k] = send(k)} end |
#reset ⇒ Object
Reset all configuration options to defaults
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/flattr/config.rb', line 74 def reset self.adapter = DEFAULT_ADAPTER self. = DEFAULT_CONNECTION_OPTIONS self.client_id = DEFAULT_CLIENT_ID self.client_secret = DEFAULT_CLIENT_SECRET self.endpoint = DEFAULT_ENDPOINT self. = DEFAULT_AUTHORIZE_ENDPOINT self.token_endpoint = DEFAULT_TOKEN_ENDPOINT self.gateway = DEFAULT_GATEWAY self.access_token = DEFAULT_ACCESS_TOKEN self.proxy = DEFAULT_PROXY self.user_agent = DEFAULT_USER_AGENT self end |