Module: BullionVault::Configuration
- Included in:
- BullionVault
- Defined in:
- lib/bullion_vault/configuration.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :adapter, :user_login, :user_password, :endpoint, :format, :proxy, :cookie, :user_agent ].freeze
- VALID_FORMATS =
[:xml].freeze
- DEFAULT_ADAPTER =
The default faraday adapter is Net::HTTP.
Faraday.default_adapter
- DEFAULT_USER_LOGIN =
nil
- DEFAULT_USER_PASSWORD =
nil
- DEFAULT_ENDPOINT =
'https://live.bullionvault.com/'.freeze
- DEFAULT_FORMAT =
'xml'.freeze
- DEFAULT_PROXY =
nil
- DEFAULT_COOKIE =
nil
- DEFAULT_USER_AGENT =
"BullionVault Ruby Gem #{BullionVault::VERSION}".freeze
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
- #authenticate ⇒ Object
-
#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
33 34 35 |
# File 'lib/bullion_vault/configuration.rb', line 33 def self.extended(base) base.reset end |
Instance Method Details
#authenticate ⇒ Object
61 62 63 64 |
# File 'lib/bullion_vault/configuration.rb', line 61 def authenticate client = Client.new client.authenticate ? (BullionVault. = client. and true) : false end |
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
38 39 40 41 |
# File 'lib/bullion_vault/configuration.rb', line 38 def configure yield self self end |
#options ⇒ Object
Create a hash of options and their values
44 45 46 |
# File 'lib/bullion_vault/configuration.rb', line 44 def Hash[VALID_OPTIONS_KEYS.map {|key| [key, public_send(key)] }] end |
#reset ⇒ Object
Reset all configuration options to defaults
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bullion_vault/configuration.rb', line 49 def reset self.adapter = DEFAULT_ADAPTER self.user_login = DEFAULT_USER_LOGIN self.user_password = DEFAULT_USER_PASSWORD self.endpoint = DEFAULT_ENDPOINT self.format = DEFAULT_FORMAT self.proxy = DEFAULT_PROXY self. = DEFAULT_COOKIE self.user_agent = DEFAULT_USER_AGENT self end |