Sha256: 88c7e9dda83c859833e95e00af115c616ecdb5f48f05d40b2d2614db9383ebbe
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
module MCollective module RPC # Simple class to manage compliant requests for MCollective::RPC agents class Request attr_accessor :time, :action, :data, :sender, :agent, :uniqid, :caller def initialize(msg) @time = msg[:msgtime] @action = msg[:body][:action] @data = msg[:body][:data] @sender = msg[:senderid] @agent = msg[:body][:agent] @uniqid = msg[:requestid] @caller = msg[:callerid] || "unknown" end # If data is a hash, quick helper to get access to it's include? method # else returns false def include?(key) return false unless @data.is_a?(Hash) return @data.include?(key) end # If no :process_results is specified always respond else respond # based on the supplied property def should_respond? return @data[:process_results] if @data.include?(:process_results) return true end # If data is a hash, gives easy access to its members, else returns nil def [](key) return nil unless @data.is_a?(Hash) return @data[key] end def to_hash return {:agent => @agent, :action => @action, :data => @data} end def to_json to_hash.merge!({:sender => @sender, :callerid => @callerid, :uniqid => @uniqid}).to_json end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mcollective-client-2.0.0 | lib/mcollective/rpc/request.rb |
mcollective-client-1.3.3 | lib/mcollective/rpc/request.rb |