1# frozen_string_literal: true
2
3require "blather"
4
5module ToForm
6 refine ::Hash do
7 def to_fields
8 map { |k, v| { var: k.to_s, value: v.to_s } }
9 end
10
11 def to_form(type)
12 Blather::Stanza::Iq::X.new(type).tap do |form|
13 form.fields = to_fields
14 end
15 end
16 end
17end