Class: OpenRosa::FormList

Inherits:
Object
  • Object
show all
Defined in:
lib/open_rosa/form_list.rb

Overview

Generates OpenRosa Form List API XML responses Spec: https://docs.getodk.org/openrosa-form-list/

Constant Summary collapse

XFORMS_LIST_NS =
"http://openrosa.org/xforms/xformsList"

Instance Method Summary collapse

Constructor Details

#initialize(forms, options = {}) ⇒ FormList

Returns a new instance of FormList.



11
12
13
14
15
16
17
# File 'lib/open_rosa/form_list.rb', line 11

def initialize(forms, options = {})
  @forms = forms
  @verbose = options.fetch(:verbose, false)
  @form_id = options[:form_id]
  @base_url = options[:base_url]
  @mount_path = options[:mount_path] || "/openrosa"
end

Instance Method Details

#to_xmlObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/open_rosa/form_list.rb', line 19

def to_xml
  builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
    xml.xforms(xmlns: XFORMS_LIST_NS) do
      filtered_forms.each do |form_class|
        generate_xform_entry(xml, form_class)
      end
    end
  end

  builder.to_xml
end