Class: Exchanger::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/exchanger/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig


7
8
9
# File 'lib/exchanger/config.rb', line 7

def initialize
  reset
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug


5
6
7
# File 'lib/exchanger/config.rb', line 5

def debug
  @debug
end

#endpointObject

Returns the value of attribute endpoint


5
6
7
# File 'lib/exchanger/config.rb', line 5

def endpoint
  @endpoint
end

#insecure_sslObject

Returns the value of attribute insecure_ssl


5
6
7
# File 'lib/exchanger/config.rb', line 5

def insecure_ssl
  @insecure_ssl
end

#passwordObject

Returns the value of attribute password


5
6
7
# File 'lib/exchanger/config.rb', line 5

def password
  @password
end

#timeoutObject

Returns the value of attribute timeout


5
6
7
# File 'lib/exchanger/config.rb', line 5

def timeout
  @timeout
end

#usernameObject

Returns the value of attribute username


5
6
7
# File 'lib/exchanger/config.rb', line 5

def username
  @username
end

Instance Method Details

#from_hash(settings) ⇒ Object

Configure Exchanger client from a hash. This is usually called after parsing a yaml config file such as exchanger.yml.

Example:

Exchanger::Config.instance.from_hash({})


27
28
29
30
31
# File 'lib/exchanger/config.rb', line 27

def from_hash(settings)
  settings.each do |name, value|
    send("#{name}=", value) if respond_to?("#{name}=")
  end
end

#resetObject

Reset the configuration options to the defaults.


12
13
14
15
16
17
18
19
# File 'lib/exchanger/config.rb', line 12

def reset
  @endpoint = nil
  @timeout = 5
  @username = nil
  @password = nil
  @debug = false
  @insecure_ssl = false
end