Module: BillysBilling::Config
- Included in:
- BillysBilling
- Defined in:
- lib/billys_billing/config.rb
Overview
Defines constants and methods related to configuration
Constant Summary collapse
- VALID_QUERIES =
[ "contact", "invoice", "organization", "payment", "product", "vat_model", "account" ]
- VALID_ACTIONS =
[ "show", # "get", "index", "list", "create", "add", "update", "destroy", "delete" ]
- DEFAULT_API_KEY =
The api key if none is set
nil
- DEFAULT_ENDPOINT =
The endpoint that will be used to connect if none is set
'https://api.billysbilling.dk/v1'
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a BillysBilling::Client
[ :api_key, :endpoint, :valid_actions, :valid_queries ]
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
47 48 49 |
# File 'lib/billys_billing/config.rb', line 47 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
52 53 54 55 |
# File 'lib/billys_billing/config.rb', line 52 def configure yield self self end |
#options ⇒ Object
Create a hash of options and their values
58 59 60 61 62 |
# File 'lib/billys_billing/config.rb', line 58 def = {} VALID_OPTIONS_KEYS.each{|k| [k] = send(k)} end |
#reset ⇒ Object
Reset all configuration options to defaults
65 66 67 68 69 70 |
# File 'lib/billys_billing/config.rb', line 65 def reset self.api_key = DEFAULT_API_KEY self.endpoint = DEFAULT_ENDPOINT self.valid_actions = VALID_ACTIONS self.valid_queries = VALID_QUERIES end |