Class: MCollective::Data::Result
- Inherits:
-
Object
- Object
- MCollective::Data::Result
show all
- Defined in:
- lib/mcollective/data/result.rb
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
9
10
11
|
# File 'lib/mcollective/data/result.rb', line 9
def initialize
@data = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/mcollective/data/result.rb', line 31
def method_missing(method, *args)
key = method.to_sym
raise NameError, "undefined local variable or method `%s'" % key unless include?(key)
@data[key]
end
|
Instance Method Details
#[](key) ⇒ Object
17
18
19
|
# File 'lib/mcollective/data/result.rb', line 17
def [](key)
@data[key.to_sym]
end
|
#[]=(key, val) ⇒ Object
21
22
23
24
25
|
# File 'lib/mcollective/data/result.rb', line 21
def []=(key, val)
raise "Can only store String, Integer, Float or Boolean data but got #{val.class} for key #{key}" unless [String, Fixnum, Bignum, Float, TrueClass, FalseClass].include?(val.class)
@data[key.to_sym] = val
end
|
#include?(key) ⇒ Boolean
13
14
15
|
# File 'lib/mcollective/data/result.rb', line 13
def include?(key)
@data.include?(key.to_sym)
end
|
#keys ⇒ Object
27
28
29
|
# File 'lib/mcollective/data/result.rb', line 27
def keys
@data.keys
end
|