Method: Osm::Grouping#update
- Defined in:
- lib/osm/grouping.rb
#update(api) ⇒ Boolan
Update the grouping in OSM
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/osm/grouping.rb', line 76 def update(api) raise Osm::ObjectIsInvalid, 'grouping is invalid' unless valid? require_ability_to(api, :read, :member, section_id) to_update = changed_attributes result = true if to_update.include?('name') || to_update.include?('active') data = api.perform_query("users.php?action=editPatrol§ionid=#{section_id}", { 'patrolid' => self.id, 'name' => name, 'active' => active, }) result &= data.nil? end if to_update.include?('points') data = api.perform_query("users.php?action=updatePatrolPoints§ionid=#{section_id}", { 'patrolid' => self.id, 'points' => points, }) result &= (data == {}) end if result reset_changed_attributes # The cached groupings for the section will be out of date - remove them Osm::Model.cache_delete(api, ['groupings', section_id]) end return result end |