1module FlashI18n
 
2  protected
 
3
  • Complexity 5 » saikuro
4  def redirect_to(url, options = {})
 
5    self.class._flash_types.each do |flash_type|
 
6      if options.key?(flash_type)
 
7        options[flash_type] = translate_flash(options[flash_type])
 
8      end
 
 9    end
 
  • Found = in conditional. It should probably be an == » roodi
11    if other_flashes = options[:flash]
 
12      other_flashes.each do |key, value|
 
13        other_flashes[key] = translate_flash(value)
 
14      end
 
15    end
 
 
17    super(url, options)
 
18  end
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 3 » saikuro
20  def translate_flash(key)
 
21    if Array === key
 
22      options = key.extract_options!
 
23      I18n.t(key.first, { scope: :"admin.flash" }.merge(options))
 
24    elsif Symbol === key
 
25      I18n.t(key, scope: :"admin.flash")
 
26    else
 
27      key
 
28    end
 
29  end
 
30end