Class: Kete
- Inherits:
-
Object
- Object
- Kete
- Defined in:
- lib/kete_translatable_content/kete.rb
Overview
overriding the system setting methods so we can pull translated versions out for translatable ones
Class Method Summary collapse
Class Method Details
.localized_value_from(setting_id) ⇒ Object
5 6 7 8 9 |
# File 'lib/kete_translatable_content/kete.rb', line 5 def localized_value_from(setting_id) return nil unless I18n.default_locale != I18n.locale SystemSetting.find(setting_id).constant_value end |
.reader_proc_for(setting) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kete_translatable_content/kete.rb', line 11 def reader_proc_for(setting) method_name = setting.constant_name.downcase Proc.new { if setting.respond_to?(:takes_translations?) && setting.takes_translations? localized_value = localized_value_from(setting.id) return localized_value if localized_value end method_name = method_name.sub('?', '') if method_name.include?('?') class_variable_get('@@' + method_name) } end |