Module: Lieu::Configuration

Included in:
Lieu
Defined in:
lib/lieu/configuration.rb

Overview

Methods for Lieu configuration

Constant Summary collapse

VALID_OPTIONS =

Configurable options

[
  :api_endpoint,
  :api_key,
  :sensor
].freeze
DEFAULT_API_ENDPOINT =

Default Google Place API endpoint

'https://maps.googleapis.com/maps/api/place/'

Instance Method Summary collapse

Instance Method Details

#configure {|_self| ... } ⇒ Object

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



22
23
24
# File 'lib/lieu/configuration.rb', line 22

def configure
  yield self
end

#initialize_default_optionsObject

Initialize default options



32
33
34
35
36
# File 'lib/lieu/configuration.rb', line 32

def initialize_default_options
  self.api_endpoint = DEFAULT_API_ENDPOINT
  self.api_key = nil
  self.sensor = false
end

#optionsObject

Default options



27
28
29
# File 'lib/lieu/configuration.rb', line 27

def options
  VALID_OPTIONS.inject({}){ |o, k| o.merge!(k => send(k)) }
end

#reset!Object

Reset configuration options to default values



39
40
41
42
43
# File 'lib/lieu/configuration.rb', line 39

def reset!
  initialize_default_options

  self
end