Module: Mobility::Backends::KeyValue::ClassMethods
- Defined in:
- lib/mobility/backends/key_value.rb
Backend Configuration collapse
- #configure(options) ⇒ Object
-
#include_cache ⇒ Object
Apply custom processing for cache plugin.
- #table_alias(attr, locale) ⇒ Object
Instance Method Summary collapse
Instance Method Details
#configure(options) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/mobility/backends/key_value.rb', line 100 def configure() [:type] &&= [:type].to_sym [:association_name] &&= [:association_name].to_sym [:class_name] &&= Util.constantize([:class_name]) [:key_column] ||= :key [:value_column] ||= :value [:belongs_to] ||= :translatable if !([:type] || ([:class_name] && [:association_name])) raise ArgumentError, "KeyValue backend requires an explicit type option, either text or string." end end |
#include_cache ⇒ Object
Apply custom processing for cache plugin
113 114 115 |
# File 'lib/mobility/backends/key_value.rb', line 113 def include_cache include self::Cache end |
#table_alias(attr, locale) ⇒ Object
117 118 119 |
# File 'lib/mobility/backends/key_value.rb', line 117 def table_alias(attr, locale) "#{model_class}_#{attr}_#{Mobility.normalize_locale(locale)}_#{[:association_name]}" end |
#valid_keys ⇒ Object
88 89 90 |
# File 'lib/mobility/backends/key_value.rb', line 88 def valid_keys [:type, :association_name, :class_name, :key_column, :value_column, :belongs_to] end |