~singpolyma/jmp-pay

ref: 092fa28a05ba09f9eaaab3f6ee2ae38bd10f36a9 jmp-pay/lib/to_form.rb -rw-r--r-- 274 bytes
092fa28aStephen Paul Weber Merge branch 'do-not-bill-unregistered' 1 year, 2 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