class Formalist::ChildForms::Builder
Constants
- MissingFormDefinitionError
Attributes
embedded_forms[R]
Public Class Methods
new(embedded_form_collection)
click to toggle source
# File lib/formalist/child_forms/builder.rb, line 10 def initialize(embedded_form_collection) @embedded_forms = embedded_form_collection end
Public Instance Methods
call(input)
click to toggle source
# File lib/formalist/child_forms/builder.rb, line 14 def call(input) return input if input.nil? input.map { |node| visit(node) } end
Also aliased as: []
Private Instance Methods
child_form(name, embedded_form)
click to toggle source
# File lib/formalist/child_forms/builder.rb, line 32 def child_form(name, embedded_form) ChildForm.build( name: name, attributes: { label: embedded_form.label, form: embedded_form.form, schema: embedded_form.schema, input_processor: embedded_form.input_processor, preview_image_url: embedded_form.preview_image_url } ) end
visit(node)
click to toggle source
# File lib/formalist/child_forms/builder.rb, line 22 def visit(node) name, data = node.values_at(:name, :data) embedded_form = embedded_forms[name] if embedded_form.nil? raise MissingFormDefinitionError, "Form +#{embedded_forms[name]}+ is missing from the embeddable forms collection" end child_form(name, embedded_form).fill(input: data) end