Class: VagrantPlugins::Orchestrate::Config::Credentials
- Inherits:
-
Object
- Object
- VagrantPlugins::Orchestrate::Config::Credentials
- Defined in:
- lib/vagrant-orchestrate/config.rb
Overview
rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
Constant Summary collapse
- UNSET_VALUE =
Same as Vagrant does to distinguish uninitialized variables and intentional assignments to Ruby’s nil, we just have to define ourselves because we’re in different scope
::Vagrant::Plugin::V2::Config::UNSET_VALUE
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#password ⇒ Object
Returns the value of attribute password.
-
#prompt ⇒ Object
Returns the value of attribute prompt.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Credentials
constructor
A new instance of Credentials.
-
#merge(new_config) ⇒ Object
Merge needs to be implemented here because this class doesn’t get to to extend Vagrant.plugin(2, :config), and it would be pretty surprising if credentials configuration defined at different levels couldn’t be merged.
- #unset? ⇒ Boolean
Constructor Details
#initialize ⇒ Credentials
Returns a new instance of Credentials.
71 72 73 74 75 76 77 |
# File 'lib/vagrant-orchestrate/config.rb', line 71 def initialize @prompt = UNSET_VALUE @file_path = UNSET_VALUE @username = UNSET_VALUE @password = UNSET_VALUE @unset = nil end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
67 68 69 |
# File 'lib/vagrant-orchestrate/config.rb', line 67 def file_path @file_path end |
#password ⇒ Object
Returns the value of attribute password.
69 70 71 |
# File 'lib/vagrant-orchestrate/config.rb', line 69 def password @password end |
#prompt ⇒ Object
Returns the value of attribute prompt.
66 67 68 |
# File 'lib/vagrant-orchestrate/config.rb', line 66 def prompt @prompt end |
#username ⇒ Object
Returns the value of attribute username.
68 69 70 |
# File 'lib/vagrant-orchestrate/config.rb', line 68 def username @username end |
Instance Method Details
#finalize! ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/vagrant-orchestrate/config.rb', line 97 def finalize! @unset = unset? @prompt = nil if @prompt == UNSET_VALUE @file_path = nil if @file_path == UNSET_VALUE @username = nil if @username == UNSET_VALUE @password = nil if @password == UNSET_VALUE end |
#merge(new_config) ⇒ Object
Merge needs to be implemented here because this class doesn’t get to to extend Vagrant.plugin(2, :config), and it would be pretty surprising if credentials configuration defined at different levels couldn’t be merged
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/vagrant-orchestrate/config.rb', line 86 def merge(new_config) result = dup unless new_config.unset? result.prompt = new_config.prompt unless new_config.prompt == UNSET_VALUE result.file_path = new_config.file_path unless new_config.file_path == UNSET_VALUE result.username = new_config.username unless new_config.username == UNSET_VALUE result.password = new_config.password unless new_config.password == UNSET_VALUE end result end |
#unset? ⇒ Boolean
79 80 81 |
# File 'lib/vagrant-orchestrate/config.rb', line 79 def unset? @unset || [@prompt, @file_path, @username, @password] == [UNSET_VALUE, UNSET_VALUE, UNSET_VALUE, UNSET_VALUE] end |