Parent

Class/Module Index [+]

Quicksearch

MCollective::RPC::Reply

Simple class to manage compliant replies to MCollective::RPC

Attributes

data[RW]
statuscode[RW]
statusmsg[RW]

Public Instance Methods

[](key) click to toggle source

Read from the data hash

# File lib/mcollective/rpc/reply.rb, line 48
def [](key)
  @data[key]
end
[]=(key, val) click to toggle source

Write to the data hash

# File lib/mcollective/rpc/reply.rb, line 43
def []=(key, val)
  @data[key] = val
end
fail(msg, code=1) click to toggle source

Helper to fill in statusmsg and code on failure

# File lib/mcollective/rpc/reply.rb, line 14
def fail(msg, code=1)
  @statusmsg = msg
  @statuscode = code
end
fail!(msg, code=1) click to toggle source

Helper that fills in statusmsg and code but also raises an appropriate error

# File lib/mcollective/rpc/reply.rb, line 20
def fail!(msg, code=1)
  @statusmsg = msg
  @statuscode = code

  case code
  when 1
    raise RPCAborted, msg

  when 2
    raise UnknownRPCAction, msg

  when 3
    raise MissingRPCData, msg

  when 4
    raise InvalidRPCData, msg

  else
    raise UnknownRPCError, msg
  end
end
to_hash() click to toggle source

Returns a compliant Hash of the reply that should be sent over the middleware

# File lib/mcollective/rpc/reply.rb, line 54
def to_hash
  return {:statuscode => @statuscode,
    :statusmsg => @statusmsg,
    :data => @data}
end

Public Class Methods

new() click to toggle source
# File lib/mcollective/rpc/reply.rb, line 7
def initialize
  @data = {}
  @statuscode = 0
  @statusmsg = "OK"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.