Class: S2Netbox::Configuration

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/s2_netbox/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#blank?, included

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
13
14
# File 'lib/s2_netbox/configuration.rb', line 9

def initialize
  @controller_url = nil
  @sha_password = nil
  @username = nil
  @password = nil
end

Instance Attribute Details

#controller_urlObject

Returns the value of attribute controller_url.



4
5
6
# File 'lib/s2_netbox/configuration.rb', line 4

def controller_url
  @controller_url
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/s2_netbox/configuration.rb', line 7

def password
  @password
end

#sha_passwordObject

Returns the value of attribute sha_password.



5
6
7
# File 'lib/s2_netbox/configuration.rb', line 5

def sha_password
  @sha_password
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/s2_netbox/configuration.rb', line 6

def username
  @username
end

Instance Method Details

#sign_with_mac?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/s2_netbox/configuration.rb', line 16

def sign_with_mac?
  !blank?(sha_password)
end

#validate!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# 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