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.
-
#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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/geoloqi/config.rb', line 75 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
24 25 26 |
# File 'lib/geoloqi/config.rb', line 24 def adapter @adapter 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).
31 32 33 |
# File 'lib/geoloqi/config.rb', line 31 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.
62 63 64 |
# File 'lib/geoloqi/config.rb', line 62 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.
50 51 52 |
# File 'lib/geoloqi/config.rb', line 50 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.
55 56 57 |
# File 'lib/geoloqi/config.rb', line 55 def use_dynamic_exceptions @use_dynamic_exceptions end |
#use_hashie_mash ⇒ Boolean
Use Hashie::Mash for return objects, which provides dot-style data retrieval.
43 44 45 |
# File 'lib/geoloqi/config.rb', line 43 def use_hashie_mash @use_hashie_mash end |
Instance Method Details
#client_id? ⇒ Boolean
Check if the OAuth2 Client ID exists.
92 93 94 |
# File 'lib/geoloqi/config.rb', line 92 def client_id? !client_id.nil? && !client_id.empty? end |
#client_secret? ⇒ Boolean
Check if OAuth2 Client Secret exists.
98 99 100 |
# File 'lib/geoloqi/config.rb', line 98 def client_secret? !client_secret.nil? && !client_secret.empty? end |