Class: FSSH::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/fssh/config.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
28
29
30
|
# File 'lib/fssh/config.rb', line 28
def method_missing(method)
@data[method]
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
8
9
10
|
# File 'lib/fssh/config.rb', line 8
def data
@data
end
|
Class Method Details
.load(content) ⇒ Object
17
18
19
20
21
|
# File 'lib/fssh/config.rb', line 17
def load(content)
result = Config.new
result.instance_variable_set(:'@data', YAML.load(content))
result
end
|
.load_file(file) ⇒ Object
11
12
13
14
15
|
# File 'lib/fssh/config.rb', line 11
def load_file(file)
result = Config.new
result.instance_variable_set(:'@data', YAML.load_file(file))
result
end
|
Instance Method Details
#[](key) ⇒ Object
24
25
26
|
# File 'lib/fssh/config.rb', line 24
def [](key)
@data[key]
end
|
#resolve_gateway(server) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/fssh/config.rb', line 32
def resolve_gateway(server)
@data[:gateway].find do |rules|
passed = true
passed &&= rules[:except].none? { |rule| server == rule } if rules[:except]
passed &&= rules[:only].include?(server) if rules[:only]
passed
end
end
|