Class: Bff::Builder
- Inherits:
-
Blocks::Builder
- Object
- Blocks::Builder
- Bff::Builder
- Defined in:
- lib/bff/builder.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#form ⇒ Object
Returns the value of attribute form.
Instance Method Summary collapse
- #field(field_name, options = {}, &block) ⇒ Object
- #form_tag(record, options = {}, &block) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #label_options(options) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 |
# File 'lib/bff/builder.rb', line 6 def initialize(*) self.fields = [] super end |
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
3 4 5 |
# File 'lib/bff/builder.rb', line 3 def fields @fields end |
#form ⇒ Object
Returns the value of attribute form.
4 5 6 |
# File 'lib/bff/builder.rb', line 4 def form @form end |
Instance Method Details
#field(field_name, options = {}, &block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/bff/builder.rb', line 11 def field(field_name, ={}, &block) if definition_mode == Blocks::Builder::DEFINITION_MODE_TEMPLATE_OVERRIDES fields << define(field_name, , &block) else render(field_name, form, field_name, , &block) end end |
#form_tag(record, options = {}, &block) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bff/builder.rb', line 19 def form_tag(record, ={}, &block) = { html: [:form_html] } [:url] = [:url] if [:url] view.form_for record, .deep_symbolize_keys do |form| @form = form view.capture(form, &block) end end |
#label_options(options) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/bff/builder.rb', line 28 def () o = [] o << [:label] if [:label] o << [:label_html] if [:label_html] o end |