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.
97 98 99 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 97 def section_data @section_data end |
Class Method Details
.parse_section_options(options) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 130 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
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 99 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
144 145 146 147 148 149 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 144 def self.section_insert_mode(symbol) { last_row: XLFormSectionInsertModeLastRow, button: XLFormSectionInsertModeButton }[symbol] || symbol || XLFormSectionInsertModeLastRow end |
.section_options(symbol) ⇒ Object
151 152 153 154 155 156 157 158 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 151 def self.(symbol) { none: XLFormSectionOptionNone, insert: XLFormSectionOptionCanInsert, delete: XLFormSectionOptionCanDelete, reorder: XLFormSectionOptionCanReorder }[symbol] || symbol || XLFormSectionOptionNone end |
Instance Method Details
#options=(value) ⇒ Object
112 113 114 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 112 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.
119 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 119 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.
124 125 126 |
# File 'lib/ProMotion/XLForm/xl_form_patch.rb', line 124 def sectionOptions @section_options || originalSectionOptions end |