class S2Netbox::Configuration

Attributes

controller_url[RW]
password[RW]
sha_password[RW]
username[RW]

Public Class Methods

new() click to toggle source
# File lib/s2_netbox/configuration.rb, line 9
def initialize
  @controller_url = nil
  @sha_password = nil
  @username = nil
  @password = nil
end

Public Instance Methods

sign_with_mac?() click to toggle source
# File lib/s2_netbox/configuration.rb, line 16
def sign_with_mac?
  !blank?(sha_password)
end
validate!() click to toggle source
# File lib/s2_netbox/configuration.rb, line 20
def validate!
  validate_controller_url!

  if !blank?(sha_password) && (!blank?(username) || !blank?(password))
    raise S2Netbox::Errors::ConfigurationError.new 'Must specify either sha_password or username and password (not both)'
  end

  if blank?(username) && blank?(password)
    validate_sha_password!
  else
    validate_username_and_password!
  end
end

Private Instance Methods

raise_error_unless(value, message=nil) click to toggle source
# File lib/s2_netbox/configuration.rb, line 50
def raise_error_unless(value, message=nil)
  if blank? value
    raise S2Netbox::Errors::ConfigurationError.new message
  end
end
validate_controller_url!() click to toggle source
# File lib/s2_netbox/configuration.rb, line 36
def validate_controller_url!
  raise_error_unless(controller_url, 'Must specify sha_password')
end
validate_sha_password!() click to toggle source
# File lib/s2_netbox/configuration.rb, line 40
def validate_sha_password!
  raise_error_unless(sha_password, 'Must specify sha_password')
end
validate_username_and_password!() click to toggle source
# File lib/s2_netbox/configuration.rb, line 44
def validate_username_and_password!
  if blank?(username) || blank?(password)
    raise S2Netbox::Errors::ConfigurationError.new 'Must specify either sha_password or username and password'
  end
end