class AllscriptsUnityClient::ClientOptions
Contains various options for Unity configuration.
Attributes
Public Class Methods
Constructor.
- options
-
:username - Unity license username for security token __(required)__.
-
:password - Unity license password for security token __(required)__.
-
:appname - Unity license appname __(required)__.
-
:proxy - A string URL pointing to an HTTP proxy (optional, primarily for debugging)
-
:logger - A Ruby object that adheres to the same interface as Logger.
-
:ca_file - A string path for a CA File on the OS (JSON only).
-
:cs_path - A string path for a CA directory (JSON only).
-
:timeout - The number of seconds to set the HTTP response timeout and keepalive timeout (JSON only).
-
:base_unity_url - The URL where a Unity server is located (i.e. unity.server.com) __(required)__
-
:ehr_userid - Allscripts EHR Username for user authentication __(required)__.
-
:ehr_password - EHR Password for user authentication __(required)__.
-
:use_ubiquity - Specifies whether the
base_unity_url
is a ubiquity endpoint
-
# File lib/allscripts_unity_client/client_options.rb, line 24 def initialize(options = {}) @username = options[:username] @password = options[:password] @appname = options[:appname] @proxy = options[:proxy] @logger = options[:logger] @ca_file = options[:ca_file] @ca_path = options[:ca_path] @timeout = options[:timeout] @ehr_userid = options[:ehr_userid] @ehr_password = options[:ehr_password] @use_ubiquity = options[:use_ubiquity] || false self.timezone = options[:timezone] self.base_unity_url = options[:base_unity_url] self.raw_dates = options[:raw_dates] validate_options end
Public Instance Methods
Mutator for appname.
Ensures appname is not nil,
# File lib/allscripts_unity_client/client_options.rb, line 93 def appname=(appname) validate_options(appname: appname) @appname = appname end
Mutator for @base_unity_url.
Strips trailing slash for URL.
# File lib/allscripts_unity_client/client_options.rb, line 62 def base_unity_url=(base_unity_url) validate_options(base_unity_url: base_unity_url) @base_unity_url = base_unity_url.gsub(/\/$/, '') end
Return true if ca_file
is not empty.
# File lib/allscripts_unity_client/client_options.rb, line 124 def ca_file? !@ca_file.to_s.strip.empty? end
Return true if ca_path
is not empty.
# File lib/allscripts_unity_client/client_options.rb, line 129 def ca_path? !@ca_path.to_s.strip.empty? end
Return true if logger is not nil.
# File lib/allscripts_unity_client/client_options.rb, line 119 def logger? !@logger.nil? end
Mutator for password.
Ensures password is not nil,
# File lib/allscripts_unity_client/client_options.rb, line 85 def password=(password) validate_options(password: password) @password = password end
Return true if proxy is set and not empty.
# File lib/allscripts_unity_client/client_options.rb, line 114 def proxy? !@proxy.to_s.strip.empty? end
# File lib/allscripts_unity_client/client_options.rb, line 109 def raw_dates=(raw_dates) @raw_dates = raw_dates || false end
Return true if timeout is not empty.
# File lib/allscripts_unity_client/client_options.rb, line 134 def timeout? !@timeout.to_s.strip.empty? end
Mutator for timezone.
Ensures timezone is not nil,
# File lib/allscripts_unity_client/client_options.rb, line 101 def timezone=(timezone) if !timezone.nil? @timezone = ActiveSupport::TimeZone[timezone] else @timezone = ActiveSupport::TimeZone['Etc/UTC'] end end
Mutator for @use_ubiquity.
defaults value to false if nil
# File lib/allscripts_unity_client/client_options.rb, line 70 def use_ubiquity=(use_ubiquity) @use_ubiquity = use_ubiquity || false end
Mutator for username.
Ensures username is not nil,
# File lib/allscripts_unity_client/client_options.rb, line 77 def username=(username) validate_options(username: username) @username = username end
Validates options by ensuring that all required options are present.
See initialize.
# File lib/allscripts_unity_client/client_options.rb, line 47 def validate_options(options = {}) base_unity_url = options.fetch(:base_unity_url, @base_unity_url) username = options.fetch(:username, @username) password = options.fetch(:password, @password) appname = options.fetch(: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