Class: XLFormRowDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/ProMotion/XLForm/xl_form_patch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cell_dataObject

Returns the value of attribute cell_data.



20
21
22
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 20

def cell_data
  @cell_data
end

Instance Method Details

#cellForFormController(form_controller) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 50

def cellForFormController(form_controller)
  unless self.cell
    cell_class = self.cellClass ? self.cellClass : XLFormViewController.cellClassesForRowDescriptorTypes[self.rowType]
    if cell_class.is_a?(String)
      bundle = NSBundle.bundleForClass(cell_class.to_s)
      if bundle.pathForResource(cell_class, ofType: "nib")
        self.cell = bundle.loadNibNamed(cell_class, owner: nil, options: nil).first
      end
    else
      self.cell = cell_class.alloc.initWithStyle(self.cellStyle, reuseIdentifier: nil)
    end

    if self.cell && self.cell.respond_to?(:setup)
      self.cell.setup(cell_data, form_controller)
    end
    self.configureCellAtCreationTime
  end

  self.cell
end

#copyWithZone(zone) ⇒ Object



24
25
26
27
28
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 24

def copyWithZone(zone)
  row_copy = old_copyWithZone(zone)
  row_copy.cell_data = cell_data
  row_copy
end

#enabled=(value) ⇒ Object



30
31
32
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 30

def enabled=(value)
  self.disabled = !value
end

#old_copyWithZoneObject



22
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 22

alias :old_copyWithZone :copyWithZone

#options=(options) ⇒ Object



34
35
36
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 34

def options=(options)
  self.selectorOptions = parse_options(options)
end

#parse_options(options) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 38

def parse_options(options)
  return nil if options.nil? || options.empty?

  options.map do |key, text|
    val = key
    if val.is_a? Symbol
      val = val.to_s
    end
    XLFormOptionsObject.formOptionsObjectWithValue(val, displayText: text)
  end
end