Class: Translatable::DatabaseStrategies::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/translatable/database_strategies/base.rb

Direct Known Subclasses

MySQL, PostgreSQL, SQLite

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_adapter(adapter_name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/translatable/database_strategies/base.rb', line 4

def self.for_adapter(adapter_name)
  case adapter_name.downcase
  when /postgresql/
    PostgreSQL.new
  when /mysql/
    MySQL.new
  when /sqlite/
    SQLite.new
  else
    raise ArgumentError, "Unsupported database adapter: #{adapter_name}"
  end
end

Instance Method Details

#column_typeObject

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/translatable/database_strategies/base.rb', line 17

def column_type
  raise NotImplementedError, "Subclasses must implement column_type"
end

#migration_example(table_name, column_name) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/translatable/database_strategies/base.rb', line 21

def migration_example(table_name, column_name)
  raise NotImplementedError, "Subclasses must implement migration_example"
end

#where_translations_scope(model_class, attributes, locales: [], case_sensitive: false) ⇒ Object

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/translatable/database_strategies/base.rb', line 25

def where_translations_scope(model_class, attributes, locales: [], case_sensitive: false)
  raise NotImplementedError, "#{self.class.name} does not support where_translations yet"
end