~singpolyma/jmp-pay

ref: 68ed9c34b0d4a2eaa0e49def372deabe4eb55daf jmp-pay/lib/to_form.rb -rw-r--r-- 274 bytes
68ed9c34Stephen Paul Weber Run billing 3 at a time 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

require "blather"

module ToForm
	refine ::Hash do
		def to_fields
			map { |k, v| { var: k.to_s, value: v.to_s } }
		end

		def to_form(type)
			Blather::Stanza::Iq::X.new(type).tap do |form|
				form.fields = to_fields
			end
		end
	end
end