Sha256: 3615a1b74cebe9db3007b385c0f93a2aaa738d184f643177c53a5d4b09131899
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
module Formalist class Form class Result class Section attr_reader :definition, :input, :rules, :errors attr_reader :children def initialize(definition, input, rules, errors) @definition = definition @input = input @rules = rules @errors = errors @children = definition.children.map { |el| el.(input, rules, errors) } end # Converts the section into an array format for including in a form's # abstract syntax tree. # # The array takes the following format: # # ``` # [:section, [params]] # ``` # # With the following parameters: # # 1. Section name # 1. Section configuration # 1. Child form elements # # @example "content" section # section.to_ast # => # # [:section, [ # # :content, # # [ # # [:some_config_name, :some_config_value] # # ], # # [ # # ...child elements... # # ] # # ]] # # @return [Array] the section as an array. def to_ast [:section, [ definition.name, definition.config.to_a, children.map(&:to_ast), ]] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
formalist-0.2.2 | lib/formalist/form/result/section.rb |
formalist-0.2.1 | lib/formalist/form/result/section.rb |
formalist-0.2.0 | lib/formalist/form/result/section.rb |