Sha256: 430a287007eb1cff7e6f202d2caed2f35813f4779e599412387e0f245138027d
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true require 'active_support/concern' require_relative 'mysql/linestring' require_relative 'mysql/multilinestring' require_relative 'mysql/point' module ActiveRecordMysqlSpatial module ActiveRecord module RegisterTypes extend ActiveSupport::Concern included do class_eval do class << self private def custom_initialize_type_map(type_map) type_map.register_type('point', MySQL::Point.new) type_map.register_type('linestring', MySQL::Linestring.new) type_map.register_type('multilinestring', MySQL::Multilinestring.new) end end remove_const('TYPE_MAP') const_set( 'TYPE_MAP', ::ActiveRecord::Type::TypeMap.new.tap do |m| initialize_type_map(m) custom_initialize_type_map(m) end ) end ::ActiveRecord::Type.register(:point, MySQL::Point, adapter: :mysql2) ::ActiveRecord::Type.register(:linestring, MySQL::Linestring, adapter: :mysql2) ::ActiveRecord::Type.register(:multilinestring, MySQL::Multilinestring, adapter: :mysql2) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems