ex.entry[:other]
end
end
+ end
+end
- class Simple
- def store_translations_with_normalisation(locale, data, options = {})
- locale = I18n::Locale::Tag::Rfc4646.tag(locale).to_s
+module OSM
+ module I18n
+ module NormaliseLocales
+ def store_translations(locale, data, options = {})
+ locale = ::I18n::Locale::Tag::Rfc4646.tag(locale).to_s
- store_translations_without_normalisation(locale, data, options)
+ super(locale, data, options)
end
-
- alias_method_chain :store_translations, :normalisation
end
- end
- module JS
- class FallbackLocales
- def default_fallbacks_with_validation
- default_fallbacks_without_validation.select do |locale|
+ module ValidateLocales
+ def default_fallbacks
+ super.select do |locale|
::I18n.available_locales.include?(locale)
end
end
-
- alias_method_chain :default_fallbacks, :validation
end
end
end
+I18n::Backend::Simple.prepend(OSM::I18n::NormaliseLocales)
+I18n::JS::FallbackLocales.prepend(OSM::I18n::ValidateLocales)
+
I18n::Backend::Simple.include(I18n::Backend::PluralizationFallback)
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
-module ActiveRecord
- module ConnectionAdapters
- module SchemaStatements
- def add_index_options_with_columns(table_name, column_name, options = {})
- columns = options.delete(:columns)
- index_name, index_type, index_columns, index_options, algorithm, using = add_index_options_without_columns(table_name, column_name, options)
- [index_name, index_type, columns || index_columns, index_options, algorithm, using]
- end
-
- alias_method_chain :add_index_options, :columns
+module OSM
+ module SchemaStatements
+ def add_index_options(table_name, column_name, options = {})
+ columns = options.delete(:columns)
+ index_name, index_type, index_columns, index_options, algorithm, using = super(table_name, column_name, options)
+ [index_name, index_type, columns || index_columns, index_options, algorithm, using]
end
+ end
- module PostgreSQL
- module Quoting
- def quote_column_name_with_arrays(name)
- Array(name).map { |n| quote_column_name_without_arrays(n) }.join(", ")
- end
-
- alias_method_chain :quote_column_name, :arrays
+ module PostgreSQL
+ module Quoting
+ def quote_column_name(name)
+ Array(name).map { |n| super(n) }.join(", ")
end
+ end
- module SchemaStatements
- def add_primary_key(table_name, column_name, _options = {})
- execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(column_name)})"
- end
+ module SchemaStatements
+ def add_primary_key(table_name, column_name, _options = {})
+ execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(column_name)})"
+ end
- def remove_primary_key(table_name)
- execute "ALTER TABLE #{quote_table_name(table_name)} DROP PRIMARY KEY"
- end
+ def remove_primary_key(table_name)
+ execute "ALTER TABLE #{quote_table_name(table_name)} DROP PRIMARY KEY"
+ end
- def alter_primary_key(table_name, new_columns)
- execute "ALTER TABLE #{quote_table_name(table_name)} DROP CONSTRAINT #{quote_table_name(table_name + '_pkey')}"
- execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(new_columns)})"
- end
+ def alter_primary_key(table_name, new_columns)
+ execute "ALTER TABLE #{quote_table_name(table_name)} DROP CONSTRAINT #{quote_table_name(table_name + '_pkey')}"
+ execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(new_columns)})"
+ end
- def create_enumeration(enumeration_name, values)
- execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')"
- end
+ def create_enumeration(enumeration_name, values)
+ execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')"
+ end
- def drop_enumeration(enumeration_name)
- execute "DROP TYPE #{enumeration_name}"
- end
+ def drop_enumeration(enumeration_name)
+ execute "DROP TYPE #{enumeration_name}"
+ end
- def rename_enumeration(old_name, new_name)
- execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
- end
+ def rename_enumeration(old_name, new_name)
+ execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
end
end
end
end
+
+ActiveRecord::ConnectionAdapters::SchemaStatements.extend(OSM::SchemaStatements)
+ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting.extend(OSM::PostgreSQL::Quoting)
+ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements.extend(OSM::PostgreSQL::SchemaStatements)