From: Andy Allan Date: Wed, 3 Jun 2020 14:44:26 +0000 (+0200) Subject: Convert lib files to model concerns X-Git-Tag: live~2828^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/0a33c66146f14e3f49dac74eff9468578a5776c0 Convert lib files to model concerns --- diff --git a/lib/consistency_validations.rb b/app/models/concerns/consistency_validations.rb similarity index 98% rename from lib/consistency_validations.rb rename to app/models/concerns/consistency_validations.rb index 7e9b33586..00c6ce993 100644 --- a/lib/consistency_validations.rb +++ b/app/models/concerns/consistency_validations.rb @@ -1,4 +1,6 @@ module ConsistencyValidations + extend ActiveSupport::Concern + # Generic checks that are run for the updates and deletes of # node, ways and relations. This code is here to avoid duplication, # and allow the extention of the checks without having to modify the diff --git a/lib/redactable.rb b/app/models/concerns/redactable.rb similarity index 57% rename from lib/redactable.rb rename to app/models/concerns/redactable.rb index 6efdae0ef..ccf04907f 100644 --- a/lib/redactable.rb +++ b/app/models/concerns/redactable.rb @@ -1,10 +1,8 @@ -require "osm" - module Redactable - def self.included(base) - # this is used to extend activerecord bases, as these aren't - # in scope for the module itself. - base.scope :unredacted, -> { where(:redaction_id => nil) } + extend ActiveSupport::Concern + + included do + scope :unredacted, -> { where(:redaction_id => nil) } end def redacted?