Class: KnifeSous::Node
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from HashMixins
normalize_hash, sanitize_key
Constructor Details
#initialize(name, config_args = {}) ⇒ Node
Returns a new instance of Node.
10
11
12
13
14
|
# File 'lib/knife_sous/node.rb', line 10
def initialize(name, config_args={})
@name = name.to_s
@config = {}
update_config(config_args)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
35
36
37
|
# File 'lib/knife_sous/node.rb', line 35
def method_missing(method_name, *args, &block)
@config[method_name.to_sym]
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8
9
10
|
# File 'lib/knife_sous/node.rb', line 8
def config
@config
end
|
#name ⇒ Object
Returns the value of attribute name.
8
9
10
|
# File 'lib/knife_sous/node.rb', line 8
def name
@name
end
|
Instance Method Details
#config_aliases ⇒ Object
39
40
41
42
43
44
|
# File 'lib/knife_sous/node.rb', line 39
def config_aliases
{
ssh_config_file: :ssh_config,
ip: :hostname
}
end
|
#convert_aliases(config_hash = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/knife_sous/node.rb', line 21
def convert_aliases(config_hash = {})
config_aliases.each do |key, value|
if config_hash.has_key?(key)
config_hash[value] = config_hash[key]
config_hash.delete(key)
end
end
config_hash
end
|
#node_name ⇒ Object
31
32
33
|
# File 'lib/knife_sous/node.rb', line 31
def node_name
@config[:node_name] || @name
end
|
#update_config(other_config = {}) ⇒ Object
16
17
18
19
|
# File 'lib/knife_sous/node.rb', line 16
def update_config(other_config={})
config = convert_aliases(normalize_hash(other_config))
@config.merge!(config)
end
|