Class: Charming::Presentation::Components::Form::Builder
- Inherits:
-
Object
- Object
- Charming::Presentation::Components::Form::Builder
- Defined in:
- lib/charming/presentation/components/form/builder.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
- #build(state:, theme: nil) ⇒ Object
- #confirm(name, **options) ⇒ Object
-
#initialize(theme: nil) ⇒ Builder
constructor
A new instance of Builder.
- #input(name, **options) ⇒ Object
- #note(text, **options) ⇒ Object
- #select(name, **options) ⇒ Object
- #textarea(name, **options) ⇒ Object
Constructor Details
#initialize(theme: nil) ⇒ Builder
Returns a new instance of Builder.
10 11 12 13 |
# File 'lib/charming/presentation/components/form/builder.rb', line 10 def initialize(theme: nil) @theme = theme @fields = [] end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
8 9 10 |
# File 'lib/charming/presentation/components/form/builder.rb', line 8 def fields @fields end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
8 9 10 |
# File 'lib/charming/presentation/components/form/builder.rb', line 8 def theme @theme end |
Instance Method Details
#build(state:, theme: nil) ⇒ Object
35 36 37 |
# File 'lib/charming/presentation/components/form/builder.rb', line 35 def build(state:, theme: nil) Components::Form.new(fields: fields, state: state, theme: theme || self.theme) end |
#confirm(name, **options) ⇒ Object
27 28 29 |
# File 'lib/charming/presentation/components/form/builder.rb', line 27 def confirm(name, **) fields << Confirm.new(name, **()) end |
#input(name, **options) ⇒ Object
15 16 17 |
# File 'lib/charming/presentation/components/form/builder.rb', line 15 def input(name, **) fields << Input.new(name, **()) end |
#note(text, **options) ⇒ Object
31 32 33 |
# File 'lib/charming/presentation/components/form/builder.rb', line 31 def note(text, **) fields << Note.new(text, **()) end |