Class: Brut::FrontEnd::Forms::ButtonInputDefinition
- Inherits:
-
Object
- Object
- Brut::FrontEnd::Forms::ButtonInputDefinition
- Includes:
- Brut::Framework::FussyTypeEnforcement
- Defined in:
- lib/brut/front_end/forms/button_input_definition.rb
Overview
Defines a button to be used to submit a form (as opposed to an <input type="submit">
).
This is needed when the name/value of the button should be submitted witih the form.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#array? ⇒ Boolean
-
#initialize(name:, array: false) ⇒ ButtonInputDefinition
constructor
Create a ButtonInputDefinition.
-
#make_input(value:, index:) ⇒ Object
Create an Input based on this definition, initializing it with the given value.
Methods included from Brut::Framework::FussyTypeEnforcement
Constructor Details
#initialize(name:, array: false) ⇒ ButtonInputDefinition
Create a ButtonInputDefinition.
14 15 16 17 18 19 20 21 |
# File 'lib/brut/front_end/forms/button_input_definition.rb', line 14 def initialize( name:, array: false ) name = name.to_s @name = type!(name, String, "name", required: true) @array = type!(array, [true, false], "array", required: true) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/brut/front_end/forms/button_input_definition.rb', line 6 def name @name end |
Instance Method Details
#array? ⇒ Boolean
23 |
# File 'lib/brut/front_end/forms/button_input_definition.rb', line 23 def array? = @array |
#make_input(value:, index:) ⇒ Object
Create an Input based on this definition, initializing it with the given value.
30 31 32 |
# File 'lib/brut/front_end/forms/button_input_definition.rb', line 30 def make_input(value:, index:) Brut::FrontEnd::Forms::Button.new(input_definition: self, value:, index:) end |