Sha256: 67f3def93403f6b3c85c71b8fef770ff0ad6c8bf6978abbf5f10f02fb2c1684a
Contents?: true
Size: 1.39 KB
Versions: 5
Compression:
Stored size: 1.39 KB
Contents
module MCollective module Data class Result # remove some methods that might clash with commonly # used return data to improve the effectiveness of the # method_missing lookup strategy undef :type if method_defined?(:type) def initialize(outputs) @data = {} outputs.each_key do |output| @data[output] = Marshal.load(Marshal.dump(outputs[output].fetch(:default, nil))) end end def include?(key) @data.include?(key.to_sym) end def [](key) @data[key.to_sym] end def []=(key, val) # checks using the string representation of the class name to avoid deprecations on Bignum and Fixnum 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) @data[key.to_sym] = val end def keys @data.keys end def respond_to_missing?(method, *) include?(method) end def method_missing(method, *args) key = method.to_sym raise NoMethodError, "undefined local variable or method `%s'" % key unless include?(key) @data[key] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems