Sha256: 31a7b1616317cc4b9bad9542df60988f5a37266b7150a4509a352fb1de074296
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
module Formalist class Form class Result class Group attr_reader :definition, :input, :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 group into an array format for including in a form's # abstract syntax tree. # # The array takes the following format: # # ``` # [:group, [params]] # ``` # # With the following parameters: # # 1. Group configuration # 1. Child form elements # # @example # group.to_ast # => # # [:group, [ # # [ # # [:some_config_name, :some_config_value] # # ], # # [ # # ...child elements... # # ] # # ]] # # @return [Array] the group as an array. def to_ast [:group, [ 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/group.rb |
formalist-0.2.1 | lib/formalist/form/result/group.rb |
formalist-0.2.0 | lib/formalist/form/result/group.rb |