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.
65 66 67 68 69 70 71 |
# File 'lib/vagrant-orchestrate/config.rb', line 65 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.
61 62 63 |
# File 'lib/vagrant-orchestrate/config.rb', line 61 def file_path @file_path end |
#password ⇒ Object
Returns the value of attribute password.
63 64 65 |
# File 'lib/vagrant-orchestrate/config.rb', line 63 def password @password end |
#prompt ⇒ Object
Returns the value of attribute prompt.
60 61 62 |
# File 'lib/vagrant-orchestrate/config.rb', line 60 def prompt @prompt end |
#username ⇒ Object
Returns the value of attribute username.
62 63 64 |
# File 'lib/vagrant-orchestrate/config.rb', line 62 def username @username end |
Instance Method Details
#finalize! ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/vagrant-orchestrate/config.rb', line 91 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
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/vagrant-orchestrate/config.rb', line 80 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
73 74 75 |
# File 'lib/vagrant-orchestrate/config.rb', line 73 def unset? @unset || [@prompt, @file_path, @username, @password] == [UNSET_VALUE, UNSET_VALUE, UNSET_VALUE, UNSET_VALUE] end |