]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/concerns/geo_record.rb
Convert some model mixins to concerns
[rails.git] / app / models / concerns / geo_record.rb
similarity index 89%
rename from lib/geo_record.rb
rename to app/models/concerns/geo_record.rb
index e02734ec909dc8064f78d2cf8e17455287939911..06049c2951b25876999cc7e3ee0fc070bacd97e6 100644 (file)
@@ -1,6 +1,8 @@
 require "delegate"
 
 module GeoRecord
 require "delegate"
 
 module GeoRecord
+  extend ActiveSupport::Concern
+
   # Ensure that when coordinates are printed that they are always in decimal degrees,
   # and not e.g. 4.0e-05
   # Unfortunately you can't extend Numeric classes directly (e.g. `Coord < Float`).
   # Ensure that when coordinates are printed that they are always in decimal degrees,
   # and not e.g. 4.0e-05
   # Unfortunately you can't extend Numeric classes directly (e.g. `Coord < Float`).
@@ -19,9 +21,9 @@ module GeoRecord
   # the database.
   SCALE = 10000000
 
   # the database.
   SCALE = 10000000
 
-  def self.included(base)
-    base.scope :bbox, ->(bbox) { base.where(OSM.sql_for_area(bbox)) }
-    base.before_save :update_tile
+  included do
+    scope :bbox, ->(bbox) { where(OSM.sql_for_area(bbox)) }
+    before_save :update_tile
   end
 
   # Is this node within -90 >= latitude >= 90 and -180 >= longitude >= 180
   end
 
   # Is this node within -90 >= latitude >= 90 and -180 >= longitude >= 180