Module: AgentXmpp::StandardLibrary::HashPatches::InstanceMethods

Defined in:
lib/agent_xmpp/patches/hash.rb

Overview


Instance Method Summary collapse

Instance Method Details

#to_x_data(type = 'result') ⇒ Object

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



10
11
12
13
14
15
# File 'lib/agent_xmpp/patches/hash.rb', line 10

def to_x_data(type = 'result')
  field_type = lambda{|v| v.kind_of?(Array) ? 'list-multi' : nil}
  inject(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