Class: Geoloqi::Config
- Inherits:
-
Object
- Object
- Geoloqi::Config
- Defined in:
- lib/geoloqi/config.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Symbol
Which HTTP adapter to use for Faraday.
-
#api_url ⇒ String
Which API URL to use for Geoloqi.
-
#client_id ⇒ String
OAuth2 Client ID for the application.
-
#client_secret ⇒ String
OAuth2 Client Secret for the application.
-
#logger ⇒ IO
Provide a logger.
-
#redirect_uri ⇒ String
OAuth2 Redirect URI.
-
#symbolize_names ⇒ Boolean
Use symbols for keys in Hash response.
-
#throw_exceptions ⇒ Boolean
Throw Geoloqi::ApiError exception on API errors.
-
#use_dynamic_exceptions ⇒ Boolean
Use dynamic error class names, which inherit from Geoloqi::ApiError.
-
#use_hashie_mash ⇒ Boolean
Use Hashie::Mash for return objects, which provides dot-style data retrieval.
Instance Method Summary collapse
-
#client_id? ⇒ Boolean
Check if the OAuth2 Client ID exists.
-
#client_secret? ⇒ Boolean
Check if OAuth2 Client Secret exists.
-
#initialize(opts = {}) ⇒ Config
constructor
Instantiate a new Geoloqi::Config object.
Constructor Details
#initialize(opts = {}) ⇒ Config
Instantiate a new Geoloqi::Config object.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/geoloqi/config.rb', line 80 def initialize(opts={}) self.use_hashie_mash ||= false self.throw_exceptions ||= true self.symbolize_names ||= true self.use_dynamic_exceptions ||= false opts.each {|k,v| send("#{k}=", v)} begin require 'hashie' if self.use_hashie_mash && !defined?(Hashie::Mash) rescue LoadError raise Error, "You've requested Hashie::Mash, but the gem is not available. Don't set use_hashie_mash in your config, or install the hashie gem" end end |
Instance Attribute Details
#adapter ⇒ Symbol
Which HTTP adapter to use for Faraday. Defaults to :net_http
29 30 31 |
# File 'lib/geoloqi/config.rb', line 29 def adapter @adapter end |
#api_url ⇒ String
Which API URL to use for Geoloqi. You shouldn't need to change this.
22 23 24 |
# File 'lib/geoloqi/config.rb', line 22 def api_url @api_url end |
#client_id ⇒ String
OAuth2 Client ID for the application. Retrieve from the Geoloqi Developers Site.
8 9 10 |
# File 'lib/geoloqi/config.rb', line 8 def client_id @client_id end |
#client_secret ⇒ String
OAuth2 Client Secret for the application. Retrieve from the Geoloqi Developers Site.
12 13 14 |
# File 'lib/geoloqi/config.rb', line 12 def client_secret @client_secret end |
#logger ⇒ IO
Provide a logger. This can be any object that responds to print and puts (anything that inherits IO).
36 37 38 |
# File 'lib/geoloqi/config.rb', line 36 def logger @logger end |
#redirect_uri ⇒ String
OAuth2 Redirect URI. This is the location the user will be redirected to after authorization from the Geoloqi OAuth2 server. If this is not provided, the user will be redirected to the URI configured at the Geoloqi Developers Site.
17 18 19 |
# File 'lib/geoloqi/config.rb', line 17 def redirect_uri @redirect_uri end |
#symbolize_names ⇒ Boolean
Use symbols for keys in Hash response. Defaults to true.
67 68 69 |
# File 'lib/geoloqi/config.rb', line 67 def symbolize_names @symbolize_names end |
#throw_exceptions ⇒ Boolean
Throw Geoloqi::ApiError exception on API errors. Defaults to true. If set to false, you will need to check for the error key in responses.
55 56 57 |
# File 'lib/geoloqi/config.rb', line 55 def throw_exceptions @throw_exceptions end |
#use_dynamic_exceptions ⇒ Boolean
Use dynamic error class names, which inherit from Geoloqi::ApiError. This may be deprecated in a future release.
60 61 62 |
# File 'lib/geoloqi/config.rb', line 60 def use_dynamic_exceptions @use_dynamic_exceptions end |
#use_hashie_mash ⇒ Boolean
Use Hashie::Mash for return objects, which provides dot-style data retrieval.
48 49 50 |
# File 'lib/geoloqi/config.rb', line 48 def use_hashie_mash @use_hashie_mash end |
Instance Method Details
#client_id? ⇒ Boolean
Check if the OAuth2 Client ID exists.
97 98 99 |
# File 'lib/geoloqi/config.rb', line 97 def client_id? !client_id.nil? && !client_id.empty? end |
#client_secret? ⇒ Boolean
Check if OAuth2 Client Secret exists.
103 104 105 |
# File 'lib/geoloqi/config.rb', line 103 def client_secret? !client_secret.nil? && !client_secret.empty? end |