Class: VagrantPlugins::Orchestrate::Config::Credentials

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeCredentials

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_pathObject

Returns the value of attribute file_path.



67
68
69
# File 'lib/vagrant-orchestrate/config.rb', line 67

def file_path
  @file_path
end

#passwordObject

Returns the value of attribute password.



69
70
71
# File 'lib/vagrant-orchestrate/config.rb', line 69

def password
  @password
end

#promptObject

Returns the value of attribute prompt.



66
67
68
# File 'lib/vagrant-orchestrate/config.rb', line 66

def prompt
  @prompt
end

#usernameObject

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

Returns:

  • (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