Class | MCollective::RPC::Reply |
In: |
lib/mcollective/rpc/reply.rb
|
Parent: | Object |
data | [RW] | |
statuscode | [RW] | |
statusmsg | [RW] |
# File lib/mcollective/rpc/reply.rb, line 7 7: def initialize 8: @data = {} 9: @statuscode = 0 10: @statusmsg = "OK" 11: end
Read from the data hash
# File lib/mcollective/rpc/reply.rb, line 48 48: def [](key) 49: @data[key] 50: end
Write to the data hash
# File lib/mcollective/rpc/reply.rb, line 43 43: def []=(key, val) 44: @data[key] = val 45: end
Helper to fill in statusmsg and code on failure
# File lib/mcollective/rpc/reply.rb, line 14 14: def fail(msg, code=1) 15: @statusmsg = msg 16: @statuscode = code 17: end
Helper that fills in statusmsg and code but also raises an appropriate error
# File lib/mcollective/rpc/reply.rb, line 20 20: def fail!(msg, code=1) 21: @statusmsg = msg 22: @statuscode = code 23: 24: case code 25: when 1 26: raise RPCAborted, msg 27: 28: when 2 29: raise UnknownRPCAction, msg 30: 31: when 3 32: raise MissingRPCData, msg 33: 34: when 4 35: raise InvalidRPCData, msg 36: 37: else 38: raise UnknownRPCError, msg 39: end 40: end