Class MCollective::RPC::Request
In: lib/mcollective/rpc/request.rb
Parent: Object

Simple class to manage compliant requests for MCollective::RPC agents

Methods

[]   include?   new   to_hash  

Attributes

action  [RW] 
agent  [RW] 
caller  [RW] 
data  [RW] 
sender  [RW] 
time  [RW] 
uniqid  [RW] 

Public Class methods

[Source]

    # File lib/mcollective/rpc/request.rb, line 7
 7:             def initialize(msg)
 8:                 @time = msg[:msgtime]
 9:                 @action = msg[:body][:action]
10:                 @data = msg[:body][:data]
11:                 @sender = msg[:senderid]
12:                 @agent = msg[:body][:agent]
13:                 @uniqid = msg[:requestid]
14:                 @caller = msg[:callerid] || "unknown"
15:             end

Public Instance methods

If data is a hash, gives easy access to its members, else returns nil

[Source]

    # File lib/mcollective/rpc/request.rb, line 25
25:             def [](key)
26:                 return nil unless @data.is_a?(Hash)
27:                 return @data[key]
28:             end

If data is a hash, quick helper to get access to it‘s include? method else returns false

[Source]

    # File lib/mcollective/rpc/request.rb, line 19
19:             def include?(key)
20:                 return false unless @data.is_a?(Hash)
21:                 return @data.include?(key)
22:             end

[Source]

    # File lib/mcollective/rpc/request.rb, line 30
30:             def to_hash
31:                 return {:agent => @agent,
32:                         :action => @action,
33:                         :data => @data}
34:             end

[Validate]