module Mobility::Backends::KeyValue::ClassMethods
Public Instance Methods
configure(options)
click to toggle source
@!group Backend
Configuration @option options [Symbol,String] type Column
type to use @option options [Symbol] association_name (:<type>_translations) Name
of association method, defaults to +<type>_translations+
@option options [Symbol] class_name Translation class, defaults to
+Mobility::<ORM>::<type>Translation+
@raise [ArgumentError] if type
is not set, and both class_name
and +association_name+ are also not set
# File lib/mobility/backends/key_value.rb, line 100 def configure(options) options[:type] &&= options[:type].to_sym options[:association_name] &&= options[:association_name].to_sym options[:class_name] &&= Util.constantize(options[:class_name]) options[:key_column] ||= :key options[:value_column] ||= :value options[:belongs_to] ||= :translatable if !(options[:type] || (options[:class_name] && options[:association_name])) raise ArgumentError, "KeyValue backend requires an explicit type option, either text or string." end end
include_cache()
click to toggle source
Apply custom processing for cache plugin
# File lib/mobility/backends/key_value.rb, line 113 def include_cache include self::Cache end
table_alias(attr, locale)
click to toggle source
# File lib/mobility/backends/key_value.rb, line 117 def table_alias(attr, locale) "#{model_class}_#{attr}_#{Mobility.normalize_locale(locale)}_#{options[:association_name]}" end
valid_keys()
click to toggle source
# File lib/mobility/backends/key_value.rb, line 88 def valid_keys [:type, :association_name, :class_name, :key_column, :value_column, :belongs_to] end