Class: Hash

Inherits:
Object show all
Defined in:
lib/agent_xmpp/patches/hash.rb

Instance Method Summary collapse

Instance Method Details

#to_x_data(type = 'result') ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



5
6
7
8
9
10
# File 'lib/agent_xmpp/patches/hash.rb', line 5

def to_x_data(type = 'result')
  field_type = lambda{|v| v.kind_of?(Array) ? 'list-multi' : nil}
  inject(AgentXmpp::Xmpp::XData.new(type)) do |data, (var, val)| 
    data.add_field_with_value(var, [val].flatten.map{|v| v.to_s}, field_type[val])
  end
end