]> git.openstreetmap.org Git - rails.git/blob - lib/redactable.rb
Improve selection logic in DiaryEntry#rss
[rails.git] / lib / redactable.rb
1 require 'osm'
2
3 module Redactable
4   def self.included(base)
5     # this is used to extend activerecord bases, as these aren't
6     # in scope for the module itself.
7     base.scope :unredacted, base.where(:redaction_id => nil)
8   end
9   
10   def redacted?
11     not self.redaction.nil?
12   end
13
14   def redact!(redaction)
15     # check that this version isn't the current version
16     raise OSM::APICannotRedactError.new if self.is_latest_version?
17
18     # make the change
19     self.redaction = redaction
20     self.save!
21   end
22 end