Module: MoipV2::Configuration
- Included in:
- MoipV2
- Defined in:
- lib/moip_v2/configuration.rb
Constant Summary collapse
- VALID_CONNECTION_KEYS =
[:endpoint, :user_agent, :method].freeze
- VALID_OPTIONS_KEYS =
[:api_token, :api_key].freeze
- VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
- DEFAULT_ENDPOINT =
'https://test.moip.com.br/v2/'
- DEFAULT_METHOD =
:get
- DEFAULT_USER_AGENT =
"Awesome API Ruby Gem #{MoipV2::VERSION}".freeze
- DEFAULT_API_TOKEN =
nil
- DEFAULT_API_KEY =
nil
Class Method Summary collapse
-
.extended(base) ⇒ Object
Make sure we have the default values set when we get ‘extended’.
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
Make sure we have the default values set when we get ‘extended’
19 20 21 |
# File 'lib/moip_v2/configuration.rb', line 19 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
23 24 25 26 27 28 |
# File 'lib/moip_v2/configuration.rb', line 23 def configure yield self if block_given? Base.site = self.endpoint Refund.site = "#{Base.site}payments/:payment_id" Payment.site = "#{Base.site}orders/:order_id/" end |
#options ⇒ Object
35 36 37 |
# File 'lib/moip_v2/configuration.rb', line 35 def Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ] end |
#reset ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/moip_v2/configuration.rb', line 39 def reset self.endpoint = DEFAULT_ENDPOINT self.method = DEFAULT_METHOD self.user_agent = DEFAULT_USER_AGENT self.api_token = DEFAULT_API_TOKEN self.api_key = DEFAULT_API_KEY end |
#test_mode ⇒ Object
30 31 32 33 |
# File 'lib/moip_v2/configuration.rb', line 30 def test_mode require "moip_v2/debug_requests" self.endpoint = DEFAULT_ENDPOINT end |