Method: CongressForms::WebForm.parse

Defined in:
lib/congress_forms/web_form.rb

.parse(spec, attrs = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/congress_forms/web_form.rb', line 7

def self.parse(spec, attrs={})
  yaml = YAML.load(spec)

  actions = yaml.dig("contact_form", "steps").map do |step|
    Actions.build(step)
  end.flatten

  new(
    actions,
    attrs.merge(
      bioguide: yaml["bioguide"],
      success_status:
        yaml.dig("contact_form", "success", "headers", "status"),
      success_content:
        yaml.dig("contact_form", "success", "body", "contains"),
    )
  )
end