Module: MetofficeDatapoint::Configuration
- Included in:
- MetofficeDatapoint
- Defined in:
- lib/metoffice_datapoint/configuration.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :api_key, :api_endpoint, :user_agent ].freeze
- DEFAULT_API_ENDPOINT =
'http://datapoint.metoffice.gov.uk/public/data/'- DEFAULT_USER_AGENT =
"Met Office DataPoint API Ruby Gem #{MetofficeDatapoint::VERSION}".freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Public: Allows configuration through a block.
- #options ⇒ Object
- #reset ⇒ Object
Class Method Details
.extended(base) ⇒ Object
17 18 19 |
# File 'lib/metoffice_datapoint/configuration.rb', line 17 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Public: Allows configuration through a block.
Yields self.
Examples
As a Rails initializer: config/initializers/metoffice_datapoint.rb
MetofficeDatapoint.configure do |config|
config.api_key = 'api_key'
end
31 32 33 |
# File 'lib/metoffice_datapoint/configuration.rb', line 31 def configure yield self end |
#options ⇒ Object
35 36 37 |
# File 'lib/metoffice_datapoint/configuration.rb', line 35 def VALID_OPTIONS_KEYS.inject({}) { |o,k| o.merge!(k => send(k)) } end |
#reset ⇒ Object
39 40 41 42 43 |
# File 'lib/metoffice_datapoint/configuration.rb', line 39 def reset self.api_key = nil self.api_endpoint = DEFAULT_API_ENDPOINT self.user_agent = DEFAULT_USER_AGENT end |