Class: Code42::Settings
- Inherits:
-
Object
- Object
- Code42::Settings
- Defined in:
- lib/code42/settings.rb
Instance Attribute Summary collapse
-
#api_root ⇒ Object
Returns the value of attribute api_root.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#host ⇒ Object
Returns the value of attribute host.
-
#https ⇒ Object
Returns the value of attribute https.
-
#mlk ⇒ Object
Returns the value of attribute mlk.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#token ⇒ Object
Returns the value of attribute token.
-
#username ⇒ Object
Returns the value of attribute username.
-
#verify_https ⇒ Object
Returns the value of attribute verify_https.
Instance Method Summary collapse
- #all ⇒ Object
- #base_url ⇒ Object
-
#initialize(options = {}) ⇒ Settings
constructor
A new instance of Settings.
- #scheme ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Settings
Returns a new instance of Settings.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/code42/settings.rb', line 5 def initialize( = {}) .symbolize_keys! self.host = [:host] self.port = [:port] self.https = ![:https].nil? ? [:https] : true self.verify_https = ![:verify_https].nil? ? [:verify_https] : true self.api_root = [:api_root] || '/api' self.username = [:username] self.password = [:password] self.token = [:token] self.debug = [:debug] end |
Instance Attribute Details
#api_root ⇒ Object
Returns the value of attribute api_root.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def api_root @api_root end |
#debug ⇒ Object
Returns the value of attribute debug.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def debug @debug end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def host @host end |
#https ⇒ Object
Returns the value of attribute https.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def https @https end |
#mlk ⇒ Object
Returns the value of attribute mlk.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def mlk @mlk end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def port @port end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def token @token end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def username @username end |
#verify_https ⇒ Object
Returns the value of attribute verify_https.
3 4 5 |
# File 'lib/code42/settings.rb', line 3 def verify_https @verify_https end |
Instance Method Details
#all ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/code42/settings.rb', line 18 def all settings = {} settings[:host] = host settings[:port] = port settings[:https] = https settings[:api_root] = api_root settings[:username] = username settings[:password] = password settings end |
#base_url ⇒ Object
33 34 35 36 |
# File 'lib/code42/settings.rb', line 33 def base_url raise Error unless valid? "#{scheme}://#{host}:#{port}#{api_root}" end |
#scheme ⇒ Object
29 30 31 |
# File 'lib/code42/settings.rb', line 29 def scheme https ? 'https' : 'http' end |
#valid? ⇒ Boolean
38 39 40 |
# File 'lib/code42/settings.rb', line 38 def valid? host && port && api_root end |