]> git.openstreetmap.org Git - rails.git/blob - lib/redactable.rb
Fix style issues found by new rubocop version
[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     !redaction.nil?
12   end
13
14   def redact!(redaction)
15     # check that this version isn't the current version
16     fail OSM::APICannotRedactError.new if self.is_latest_version?
17
18     # make the change
19     self.redaction = redaction
20     self.save!
21   end
22 end