Class: XLFormSectionDescriptor
- Inherits:
-
Object
- Object
- XLFormSectionDescriptor
- Defined in:
- lib/ProMotion/XLForm/xl_form_patch.rb
Instance Attribute Summary collapse
-
#section_data ⇒ Object
Returns the value of attribute section_data.
Class Method Summary collapse
- .parse_section_options(options) ⇒ Object
- .section(section_data) ⇒ Object
- .section_insert_mode(symbol) ⇒ Object
- .section_options(symbol) ⇒ Object
Instance Method Summary collapse
- #options=(value) ⇒ Object
-
#originalSectionOptions ⇒ Object
Since ‘sectionOptions` is a property on the Objective-C class and not a Ruby method we can’t use ‘super` to fallback when overriding the method.
-
#sectionOptions ⇒ Object
(also: #options)
This property/method is used in the Objective-C initializer and is called before we ever have a chance to set @section_options so we need to be able to fallback to the original.
Instance Attribute Details
#section_data ⇒ Object
Returns the value of attribute section_data.
99 100 101 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 99 def section_data @section_data end |
Class Method Details
.parse_section_options(options) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 132 def self.() return (:none) if .nil? opts = (:none) unless .is_a?(Array) = [] end .each do |opt| opts |= (opt) end opts end |
.section(section_data) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 101 def self.section(section_data) title = section_data[:title] = section_data.fetch(:options, :none) = () insert_mode = section_insert_mode(section_data[:insert_mode]) section = XLFormSectionDescriptor.formSectionWithTitle(title, sectionOptions: , sectionInsertMode: insert_mode) section.section_data = section_data section end |
.section_insert_mode(symbol) ⇒ Object
146 147 148 149 150 151 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 146 def self.section_insert_mode(symbol) { last_row: XLFormSectionInsertModeLastRow, button: XLFormSectionInsertModeButton }[symbol] || symbol || XLFormSectionInsertModeLastRow end |
.section_options(symbol) ⇒ Object
153 154 155 156 157 158 159 160 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 153 def self.(symbol) { none: XLFormSectionOptionNone, insert: XLFormSectionOptionCanInsert, delete: XLFormSectionOptionCanDelete, reorder: XLFormSectionOptionCanReorder }[symbol] || symbol || XLFormSectionOptionNone end |
Instance Method Details
#options=(value) ⇒ Object
114 115 116 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 114 def (value) @section_options = self.class.(value) end |
#originalSectionOptions ⇒ Object
Since ‘sectionOptions` is a property on the Objective-C class and not a Ruby method we can’t use ‘super` to fallback when overriding the method. To achieve the same thing we create an alias and use that instead.
121 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 121 alias :originalSectionOptions :sectionOptions |
#sectionOptions ⇒ Object Also known as: options
This property/method is used in the Objective-C initializer and is called before we ever have a chance to set @section_options so we need to be able to fallback to the original.
126 127 128 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 126 def sectionOptions @section_options || originalSectionOptions end |