/
locotimezone.rb
38 lines (33 loc) · 1013 Bytes
/
locotimezone.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'locotimezone/version'
require 'locotimezone/locotime'
require 'locotimezone/geolocate'
require 'locotimezone/timezone'
require 'locotimezone/errors'
require 'locotimezone/error_logger'
require 'locotimezone/configuration'
require 'locotimezone/results_formatter'
require 'locotimezone/active_record_helper'
require 'locotimezone/railtie' if defined?(Rails)
module Locotimezone
class << self
attr_accessor :configuration
end
def self.locotime(options = {})
configure_with_defaults if configuration.nil?
Locotime.new(location: options[:location],
address: options[:address],
skip: options[:skip]).call
end
def self.configure
self.configuration ||= Configuration.new
yield configuration if block_given?
self
end
def self.reset_configuration
self.configuration = Configuration.new
configure_with_defaults
end
def self.configure_with_defaults
Locotimezone.configure { |config| config.google_api_key = '' }
end
end