Class: S2Netbox::Configuration
- Inherits:
-
Object
- Object
- S2Netbox::Configuration
- Includes:
- Helpers
- Defined in:
- lib/s2_netbox/configuration.rb
Instance Attribute Summary collapse
-
#controller_url ⇒ Object
Returns the value of attribute controller_url.
-
#password ⇒ Object
Returns the value of attribute password.
-
#sha_password ⇒ Object
Returns the value of attribute sha_password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #sign_with_mac? ⇒ Boolean
- #validate! ⇒ Object
Methods included from Helpers
Constructor Details
#initialize ⇒ Configuration
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_url ⇒ Object
Returns the value of attribute controller_url.
4 5 6 |
# File 'lib/s2_netbox/configuration.rb', line 4 def controller_url @controller_url end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/s2_netbox/configuration.rb', line 7 def password @password end |
#sha_password ⇒ Object
Returns the value of attribute sha_password.
5 6 7 |
# File 'lib/s2_netbox/configuration.rb', line 5 def sha_password @sha_password end |
#username ⇒ Object
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
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 |