Skip to content

Commit

Permalink
I18n performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
yulii committed Oct 1, 2013
1 parent 43fd6a7 commit eda303b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions lib/rescue/controllers/flash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ module Controller
class Flash

def self.message object, key
scope = [:views]
scope += object.controller_path.split('/')
scope << object.action_name
scope << :flash
scope = "views.#{object.controller_path.gsub(%r{/}, '.')}.#{object.action_name}.flash"
text(key, scope)
end

# Private Methods
def self.default key
s = I18n.t(key, scope: [:default, :flash], default: '')
s = I18n.t("default.flash.#{key}", default: '')
s.blank? ? nil : s
end

def self.text key, scope = []
s = I18n.t(key, scope: scope, default: '')
def self.text key, scope
s = I18n.t("#{scope}.#{key}", default: '')
s.blank? ? default(key) : s
end
private_class_method :default, :text
Expand Down
2 changes: 1 addition & 1 deletion lib/rescue/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Rescue
VERSION = "0.3.5"
VERSION = "0.3.6"
end

0 comments on commit eda303b

Please sign in to comment.