Class: Bff::Builder

Inherits:
Blocks::Builder
  • Object
show all
Defined in:
lib/bff/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

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

#fieldsObject

Returns the value of attribute fields.



3
4
5
# File 'lib/bff/builder.rb', line 3

def fields
  @fields
end

#formObject

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, options={}, &block)
  if definition_mode == Blocks::Builder::DEFINITION_MODE_TEMPLATE_OVERRIDES
    fields << define(field_name, options, &block)
  else
    render(field_name, form, field_name, options, &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, options={}, &block)
  form_options = { html: options[:form_html] }
  form_options[:url] = options[:url] if options[:url]
  view.form_for record, form_options.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 label_options(options)
  o = []
  o << options[:label] if options[:label]
  o << options[:label_html] if options[:label_html]
  o
end