Method: Osm::Event#add_column
- Defined in:
- lib/osm/event.rb
#add_column(api, name, label = '', required = false) ⇒ Boolean
Add a column to the event in OSM
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/osm/event.rb', line 311 def add_column(api, name, label='', required=false) require_ability_to(api, :write, :events, section_id) raise Osm::ArgumentIsInvalid, 'name is invalid' if name.blank? data = api.perform_query("events.php?action=addColumn§ionid=#{section_id}&eventid=#{id}", { 'columnName' => name, 'parentLabel' => label, 'parentRequire' => (required ? 1 : 0), }) # The cached events for the section will be out of date - remove them cache_delete(api, ['events', section_id]) cache_delete(api, ['event', id]) cache_delete(api, ['event_attendance', id]) self.columns = self.class.new_event_from_data(data).columns return data.is_a?(Hash) && (data['eventid'].to_i == id) end |