class Osm::FlexiRecord::Data
Constants
- SORT_BY
Public Instance Methods
<=>(another)
click to toggle source
Compare Data
based on flexi_record, grouping_id then member_id
# File lib/osm/flexi_record.rb, line 324 def <=>(another) result = self.flexi_record <=> another.try(:flexi_record) result = self.grouping_id <=> another.try(:grouping_id) if result == 0 result = self.member_id <=> another.try(:member_id) if result == 0 return result end
inspect()
click to toggle source
# File lib/osm/flexi_record.rb, line 331 def inspect Osm.inspect_instance(self, options={:replace_with => {'flexi_record' => :id}}) end
update(api)
click to toggle source
Update data in OSM @param [Osm::Api] api The api to use to make the request @return [Boolean] whether the data was updated in OSM @raise [Osm::ObjectIsInvalid] If the Data
is invalid
# File lib/osm/flexi_record.rb, line 284 def update(api) raise Osm::ObjectIsInvalid, 'data is invalid' unless valid? require_ability_to(api, :write, :flexi, flexi_record.section_id) term_id = Osm::Term.get_current_term_for_section(api, flexi_record.section_id).id updated = true editable_fields = flexi_record.get_columns(api).select{ |c| c.editable }.map{ |i| i.id } fields.changes.each do |field, (was,now)| if editable_fields.include?(field) data = api.perform_query("extras.php?action=updateScout", { 'termid' => term_id, 'scoutid' => self.member_id, 'column' => field, 'value' => now, 'sectionid' => flexi_record.section_id, 'extraid' => flexi_record.id, }) if (data.is_a?(Hash) && data['items'].is_a?(Array)) data['items'].each do |item| if item['scoutid'] == member_id.to_s # Find this member from the list of all members updated = false unless item[field] == now end end else updated = false end end end if updated fields.clean_up! # The cached datas for the flexi record will be out of date - remove them cache_delete(api, ['flexi_record_data', flexi_record.id]) end return updated end