Module: Gistance::Configuration
- Included in:
- Gistance
- Defined in:
- lib/gistance/configuration.rb
Overview
Methods for Gistance configuration
Constant Summary collapse
- VALID_OPTIONS =
Configurable options
[ :api_endpoint, :api_key, :language, :units, :sensor, :business ].freeze
- DEFAULT_API_ENDPOINT =
Default Google Distance Matrix API endpoint
'https://maps.googleapis.com/maps/api/distancematrix/json'
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Set configuration options using a block.
-
#initialize_default_options ⇒ Object
Initialize default options.
-
#options ⇒ Object
Default options.
-
#reset! ⇒ Object
Reset configuration options to default values.
Instance Method Details
#configure {|_self| ... } ⇒ Object
Set configuration options using a block
25 26 27 |
# File 'lib/gistance/configuration.rb', line 25 def configure yield self end |
#initialize_default_options ⇒ Object
Initialize default options
35 36 37 38 39 40 41 42 |
# File 'lib/gistance/configuration.rb', line 35 def self.api_endpoint = DEFAULT_API_ENDPOINT self.api_key = nil self.language = 'en' self.units = 'metric' self.sensor = false self.business = nil end |
#options ⇒ Object
Default options
30 31 32 |
# File 'lib/gistance/configuration.rb', line 30 def VALID_OPTIONS.inject({}){ |o, k| o.merge!(k => send(k)) } end |
#reset! ⇒ Object
Reset configuration options to default values
45 46 47 48 49 |
# File 'lib/gistance/configuration.rb', line 45 def reset! self end |