Class: Formalist::Form::Definition::Many
- Inherits:
-
Object
- Object
- Formalist::Form::Definition::Many
- Defined in:
- lib/formalist/form/definition/many.rb
Constant Summary collapse
- ALLOWED_CHILDREN =
%w[ attr component group field ].freeze
- DEFAULT_CONFIG =
{ allow_create: true, allow_update: true, allow_destroy: true, allow_reorder: true }.freeze
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(input, rules, errors) ⇒ Object
-
#initialize(name, config = {}, children = []) ⇒ Many
constructor
A new instance of Many.
Constructor Details
#initialize(name, config = {}, children = []) ⇒ Many
Returns a new instance of Many.
25 26 27 28 29 30 31 32 33 |
# File 'lib/formalist/form/definition/many.rb', line 25 def initialize(name, 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 @name = name @config = DEFAULT_CONFIG.merge(config) @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
23 24 25 |
# File 'lib/formalist/form/definition/many.rb', line 23 def children @children end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/formalist/form/definition/many.rb', line 22 def config @config end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/formalist/form/definition/many.rb', line 21 def name @name end |