Move monkey patch modules to the OpenStreetMap namespace

Having them in the OSM namespace risks blocking autoloading
of the lib/osm.rb code by defining the OSM constant.
This commit is contained in:
Tom Hughes 2017-06-02 15:38:45 +01:00
parent 5b33f3f8e3
commit f8f7054fc2
4 changed files with 10 additions and 10 deletions

View file

@ -1,5 +1,5 @@
if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdapter)
module OSM
module OpenStreetMap
module AbstractAdapter
module PropagateTimeouts
def translate_exception_class(e, sql)
@ -13,5 +13,5 @@ if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdapter)
end
end
ActiveRecord::ConnectionAdaptors::AbstractAdapter.prepend(OSM::AbstractAdapter::PropagateTimeouts)
ActiveRecord::ConnectionAdaptors::AbstractAdapter.prepend(OpenStreetMap::AbstractAdapter::PropagateTimeouts)
end

View file

@ -11,7 +11,7 @@ module I18n
end
end
module OSM
module OpenStreetMap
module I18n
module NormaliseLocales
def store_translations(locale, data, options = {})
@ -31,8 +31,8 @@ module OSM
end
end
I18n::Backend::Simple.prepend(OSM::I18n::NormaliseLocales)
I18n::JS::FallbackLocales.prepend(OSM::I18n::ValidateLocales)
I18n::Backend::Simple.prepend(OpenStreetMap::I18n::NormaliseLocales)
I18n::JS::FallbackLocales.prepend(OpenStreetMap::I18n::ValidateLocales)
I18n::Backend::Simple.include(I18n::Backend::PluralizationFallback)
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)

View file

@ -1,7 +1,7 @@
# Some versions of ruby seem to accidentally force the encoding
# as part of normalize_path and some don't
module OSM
module OpenStreetMap
module Router
module ForceEncoding
def normalize_path(path)
@ -11,4 +11,4 @@ module OSM
end
end
ActionDispatch::Journey::Router::Utils.singleton_class.prepend(OSM::Router::ForceEncoding)
ActionDispatch::Journey::Router::Utils.singleton_class.prepend(OpenStreetMap::Router::ForceEncoding)

View file

@ -1,4 +1,4 @@
module OSM
module OpenStreetMap
module ActiveRecord
module AbstractAdapter
def add_index_options(table_name, column_name, options = {})
@ -41,5 +41,5 @@ module OSM
end
end
ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(OSM::ActiveRecord::AbstractAdapter)
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(OSM::ActiveRecord::PostgreSQLAdapter)
ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(OpenStreetMap::ActiveRecord::AbstractAdapter)
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(OpenStreetMap::ActiveRecord::PostgreSQLAdapter)