class MCollective::Data::Result
Public Class Methods
new(outputs)
click to toggle source
# File lib/mcollective/data/result.rb 9 def initialize(outputs) 10 @data = {} 11 12 outputs.keys.each do |output| 13 @data[output] = Marshal.load(Marshal.dump(outputs[output].fetch(:default, nil))) 14 end 15 end
Public Instance Methods
[](key)
click to toggle source
# File lib/mcollective/data/result.rb 21 def [](key) 22 @data[key.to_sym] 23 end
[]=(key, val)
click to toggle source
# File lib/mcollective/data/result.rb 25 def []=(key, val) 26 # checks using the string representation of the class name to avoid deprecations on Bignum and Fixnum 27 raise "Can only store String, Integer, Float or Boolean data but got #{val.class} for key #{key}" unless ["String", "Integer", "Bignum", "Fixnum", "Float", "TrueClass", "FalseClass"].include?(val.class.to_s) 28 29 @data[key.to_sym] = val 30 end
include?(key)
click to toggle source
# File lib/mcollective/data/result.rb 17 def include?(key) 18 @data.include?(key.to_sym) 19 end
keys()
click to toggle source
# File lib/mcollective/data/result.rb 32 def keys 33 @data.keys 34 end
method_missing(method, *args)
click to toggle source
# File lib/mcollective/data/result.rb 36 def method_missing(method, *args) 37 key = method.to_sym 38 39 raise NoMethodError, "undefined local variable or method `%s'" % key unless include?(key) 40 41 @data[key] 42 end