Module: Tidas::Configuration
- Defined in:
- lib/tidas/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Class Method Summary collapse
- .api_key ⇒ Object
- .application ⇒ Object
- .clear_configuration(flag) ⇒ Object
- .configure(attributes = {}) ⇒ Object
- .server ⇒ Object
-
.test_configure ⇒ Object
:nodoc#.
- .timeout ⇒ Object
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/tidas/configuration.rb', line 4 def api_key @api_key end |
#application ⇒ Object (readonly)
Returns the value of attribute application.
4 5 6 |
# File 'lib/tidas/configuration.rb', line 4 def application @application end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
4 5 6 |
# File 'lib/tidas/configuration.rb', line 4 def server @server end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/tidas/configuration.rb', line 4 def timeout @timeout end |
Class Method Details
.api_key ⇒ Object
51 52 53 |
# File 'lib/tidas/configuration.rb', line 51 def self.api_key @api_key end |
.application ⇒ Object
55 56 57 |
# File 'lib/tidas/configuration.rb', line 55 def self.application @application end |
.clear_configuration(flag) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/tidas/configuration.rb', line 38 def self.clear_configuration(flag) case flag when :server then @server = nil when :api_key then @api_key = nil when :application then @application = nil when :timeout then @timeout = nil end end |
.configure(attributes = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tidas/configuration.rb', line 15 def self.configure(attributes={}) server = attributes.fetch(:server,ENV['tidas_server']) api_key = attributes.fetch(:api_key,ENV['tidas_api_key']) application = attributes.fetch(:application,ENV['tidas_application']) timeout = attributes.fetch(:timeout,ENV['tidas_timeout']) if server @server = server end if api_key @api_key = api_key end if application @application = application end if timeout @timeout = timeout.to_s end end |
.server ⇒ Object
47 48 49 |
# File 'lib/tidas/configuration.rb', line 47 def self.server @server end |
.test_configure ⇒ Object
:nodoc#
6 7 8 9 10 11 12 13 |
# File 'lib/tidas/configuration.rb', line 6 def self.test_configure #:nodoc# Configuration.configure( server: 'http://localhost:3000', api_key: 'test-api-key', application: 'Javelin', timeout: 1 ) end |
.timeout ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/tidas/configuration.rb', line 59 def self.timeout if @timeout @timeout.to_i else 20 end end |