Class: AllscriptsUnityClient::ClientOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/allscripts_unity_client/client_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ClientOptions

Returns a new instance of ClientOptions.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def initialize(options = {})
  @base_unity_url = options[:base_unity_url] ? options[:base_unity_url].gsub(/\/$/, '') : nil
  @username = options[:username]
  @password = options[:password]
  @appname = options[:appname]
  @proxy = options[:proxy]
  self.timezone = options[:timezone]
  @logger = options[:logger]

  validate_options
end

Instance Attribute Details

#appnameObject

Returns the value of attribute appname.



4
5
6
# File 'lib/allscripts_unity_client/client_options.rb', line 4

def appname
  @appname
end

#base_unity_urlObject

Returns the value of attribute base_unity_url.



4
5
6
# File 'lib/allscripts_unity_client/client_options.rb', line 4

def base_unity_url
  @base_unity_url
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/allscripts_unity_client/client_options.rb', line 3

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/allscripts_unity_client/client_options.rb', line 4

def password
  @password
end

#proxyObject

Returns the value of attribute proxy.



3
4
5
# File 'lib/allscripts_unity_client/client_options.rb', line 3

def proxy
  @proxy
end

#timezoneObject

Returns the value of attribute timezone.



4
5
6
# File 'lib/allscripts_unity_client/client_options.rb', line 4

def timezone
  @timezone
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/allscripts_unity_client/client_options.rb', line 4

def username
  @username
end

Instance Method Details

#logger?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/allscripts_unity_client/client_options.rb', line 64

def logger?
  !@logger.nil?
end

#proxy?Boolean

Returns:

  • (Boolean)


58
59
60
61
62
# File 'lib/allscripts_unity_client/client_options.rb', line 58

def proxy?
  return false if @proxy.nil?
  return false if @proxy.empty?
  true
end

#validate_options(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/allscripts_unity_client/client_options.rb', line 18

def validate_options(options = {})
  base_unity_url = options.has_key?(:base_unity_url) ? options[:base_unity_url] : @base_unity_url
  username = options.has_key?(:username) ? options[:username] : @username
  password = options.has_key?(:password) ? options[:password] : @password
  appname = options.has_key?(:appname) ? options[:appname] : @appname

  raise ArgumentError, 'base_unity_url can not be nil' if base_unity_url.nil?
  raise ArgumentError, 'username can not be nil' if username.nil?
  raise ArgumentError, 'password can not be nil' if password.nil?
  raise ArgumentError, 'appname can not be nil' if appname.nil?
end