Class: Formalist::Form::Result::Group
- Inherits:
-
Object
- Object
- Formalist::Form::Result::Group
- Defined in:
- lib/formalist/form/result/group.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(definition, input, rules, errors) ⇒ Group
constructor
A new instance of Group.
-
#to_ast ⇒ Array
Converts the group into an array format for including in a form's abstract syntax tree.
Constructor Details
#initialize(definition, input, rules, errors) ⇒ Group
Returns a new instance of Group.
8 9 10 11 12 13 14 |
# File 'lib/formalist/form/result/group.rb', line 8 def initialize(definition, input, rules, errors) @definition = definition @input = input @rules = rules @errors = errors @children = definition.children.map { |el| el.(input, rules, errors) } end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
6 7 8 |
# File 'lib/formalist/form/result/group.rb', line 6 def children @children end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'lib/formalist/form/result/group.rb', line 5 def definition @definition end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/formalist/form/result/group.rb', line 5 def errors @errors end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
5 6 7 |
# File 'lib/formalist/form/result/group.rb', line 5 def input @input end |
Instance Method Details
#to_ast ⇒ Array
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:
- Group configuration
- Child form elements
42 43 44 45 46 47 |
# File 'lib/formalist/form/result/group.rb', line 42 def to_ast [:group, [ definition.config.to_a, children.map(&:to_ast), ]] end |