module Sequel::Plugins::Localize::InstanceMethods
Public Instance Methods
after_save()
click to toggle source
# File lib/sequel/localize.rb, line 85 def after_save each_translation do |locale, translation| if translation.pk translation.save else add_translation(translation) end end end
default_locale()
click to toggle source
# File lib/sequel/localize.rb, line 95 def default_locale 'de' end
translation(locale)
click to toggle source
# File lib/sequel/localize.rb, line 99 def translation(locale) l = Language[locale] (@_translations ||= {})[locale.to_sym] ||= if pk translations_dataset.where(:language_id => l.id).first end || self.class.translation_class.new(:language_id => l.id) end
validate()
click to toggle source
Calls superclass method
# File lib/sequel/localize.rb, line 107 def validate super each_translation do |locale, translation| errors.add(locale, translation.errors) unless translation.valid? end end
Private Instance Methods
each_translation(&block)
click to toggle source
# File lib/sequel/localize.rb, line 116 def each_translation(&block) return unless @_translations @_translations.each(&block) end