Class: Formalist::Form::Definition::Group
- Inherits:
-
Object
- Object
- Formalist::Form::Definition::Group
- Defined in:
- lib/formalist/form/definition/group.rb
Constant Summary collapse
- ALLOWED_CHILDREN =
%w[ attr component field many ].freeze
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(input, rules, errors) ⇒ Object
-
#initialize(config = {}, children = []) ⇒ Group
constructor
A new instance of Group.
Constructor Details
#initialize(config = {}, children = []) ⇒ Group
Returns a new instance of Group.
16 17 18 19 20 21 22 23 |
# File 'lib/formalist/form/definition/group.rb', line 16 def initialize(config = {}, children = []) unless children.all? { |c| ALLOWED_CHILDREN.include?(Inflecto.underscore(c.class.name).split("/").last) } raise ArgumentError, "children must be +#{ALLOWED_CHILDREN.join(', ')}+" end @config = config @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
14 15 16 |
# File 'lib/formalist/form/definition/group.rb', line 14 def children @children end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/formalist/form/definition/group.rb', line 14 def config @config end |
Instance Method Details
#call(input, rules, errors) ⇒ Object
25 26 27 |
# File 'lib/formalist/form/definition/group.rb', line 25 def call(input, rules, errors) Result::Group.new(self, input, rules, errors) end |