Class MCollective::RPC::Result
In: lib/mcollective/rpc/result.rb
Parent: Object

Simple class to manage compliant results from MCollective::RPC agents

Currently it just fakes Hash behaviour to the result to remain backward compatible but it also knows which agent and action produced it so you can associate results to a DDL

Methods

[]   []=   each   fetch   new   to_json  

Included Modules

Enumerable

Attributes

action  [R] 
agent  [R] 
results  [R] 

Public Class methods

[Source]

    # File lib/mcollective/rpc/result.rb, line 13
13:       def initialize(agent, action, result={})
14:         @agent = agent
15:         @action = action
16:         @results = result
17:       end

Public Instance methods

[Source]

    # File lib/mcollective/rpc/result.rb, line 19
19:       def [](idx)
20:         @results[idx]
21:       end

[Source]

    # File lib/mcollective/rpc/result.rb, line 23
23:       def []=(idx, item)
24:         @results[idx] = item
25:       end

[Source]

    # File lib/mcollective/rpc/result.rb, line 31
31:       def each
32:         @results.each_pair {|k,v| yield(k,v) }
33:       end

[Source]

    # File lib/mcollective/rpc/result.rb, line 27
27:       def fetch(key, default)
28:         @results.fetch(key, default)
29:       end

[Source]

    # File lib/mcollective/rpc/result.rb, line 35
35:       def to_json(*a)
36:         {:agent => @agent,
37:          :action => @action,
38:          :sender => @results[:sender],
39:          :statuscode => @results[:statuscode],
40:          :statusmsg => @results[:statusmsg],
41:          :data => @results[:data]}.to_json(*a)
42:       end

[Validate]