# class MCollective::RPC::Result

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

### Attributes

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

### Public Class Methods

new(agent, action, result={}) click to toggle source

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

### Public Instance Methods

[](idx) click to toggle source

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

[]=(idx, item) click to toggle source

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

each() { |k,v| ... } click to toggle source

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

fetch(key, default) click to toggle source

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

to_json(*a) click to toggle source

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