Method: Mobility::Backends::Sequel::KeyValue.configure

Defined in:
lib/mobility/backends/sequel/key_value.rb

.configure(options) ⇒ Object

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • type (Symbol, String)

    Column type to use

  • association_name (Symbol) — default: :<type>_translations

    Name of association method, defaults to <type>_translations

  • class_name (Symbol)

    Translation class, defaults to Mobility::<ORM>::<type>Translation

Raises:

  • (CacheRequired)

    if cache is disabled

  • (ArgumentError)

    if type is not set, and both class_name and association_name are also not set



28
29
30
31
32
33
34
35
36
37
# File 'lib/mobility/backends/sequel/key_value.rb', line 28

def configure(options)
  raise CacheRequired, "Cache required for Sequel::KeyValue backend" if options[:cache] == false
  super
  if type = options[:type]
    options[:association_name] ||= :"#{options[:type]}_translations"
    options[:class_name]       ||= const_get("#{type.capitalize}Translation")
  end
rescue NameError
  raise ArgumentError, "You must define a Mobility::Sequel::#{type.capitalize}Translation class."
end