Class: Caisson::Helpers::Form::Builder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/caisson/helpers/form/builder/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(core, record) ⇒ Base

************************************************************************************* CONSTRUCTOR *************************************************************************************



8
9
10
11
12
# File 'lib/caisson/helpers/form/builder/base.rb', line 8

def initialize(core, record)
  @core = core
  @record = record
  @interpreti = Caisson::Helpers::Form::Builder::Interpreti.new(@record)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object (private)



70
# File 'lib/caisson/helpers/form/builder/base.rb', line 70

def method_missing(*args, &block) return @core.send(*args, &block) end

Instance Attribute Details

#interpretiObject (readonly)

Returns the value of attribute interpreti.



3
4
5
# File 'lib/caisson/helpers/form/builder/base.rb', line 3

def interpreti
  @interpreti
end

#recordObject (readonly)

Returns the value of attribute record.



3
4
5
# File 'lib/caisson/helpers/form/builder/base.rb', line 3

def record
  @record
end

Instance Method Details

#line(field_name, options = {}) ⇒ Object

************************************************************************************* PUBLIC INSTANCE METHODS *************************************************************************************



18
19
20
21
22
23
24
25
26
# File 'lib/caisson/helpers/form/builder/base.rb', line 18

def line(field_name, options={})
  options.reverse_merge!(choices: nil, hint: true, id: 'undefined', label: 'undefined', nature: nil, placeholder: false, value: 'undefined')

  field = field_builder(field_name, field_options(options))

  label_str = line_label(field, force: options[:label])

  return caisson.line(label_str, field.build, line_options(field, options))
end

#line_label(field, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/caisson/helpers/form/builder/base.rb', line 28

def line_label(field, options={})
  options.reverse_merge!(force: 'undefined')

  return case
    when options[:force] != 'undefined' then options[:force]
    when field.checkbox? then nil
    when field.hidden? then nil
    else field.label
  end
end