Class: VagrantPlugins::Orchestrate::Config::Credentials
- Inherits:
-
Object
- Object
- VagrantPlugins::Orchestrate::Config::Credentials
- Defined in:
- lib/vagrant-orchestrate/config.rb
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.
57 58 59 60 61 62 63 |
# File 'lib/vagrant-orchestrate/config.rb', line 57 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.
53 54 55 |
# File 'lib/vagrant-orchestrate/config.rb', line 53 def file_path @file_path end |
#password ⇒ Object
Returns the value of attribute password.
55 56 57 |
# File 'lib/vagrant-orchestrate/config.rb', line 55 def password @password end |
#prompt ⇒ Object
Returns the value of attribute prompt.
52 53 54 |
# File 'lib/vagrant-orchestrate/config.rb', line 52 def prompt @prompt end |
#username ⇒ Object
Returns the value of attribute username.
54 55 56 |
# File 'lib/vagrant-orchestrate/config.rb', line 54 def username @username end |
Instance Method Details
#finalize! ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/vagrant-orchestrate/config.rb', line 83 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
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vagrant-orchestrate/config.rb', line 72 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
65 66 67 |
# File 'lib/vagrant-orchestrate/config.rb', line 65 def unset? @unset || [@prompt, @file_path, @username, @password] == [UNSET_VALUE, UNSET_VALUE, UNSET_VALUE, UNSET_VALUE] end |