aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tags/translator.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-05 15:27:45 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-05 15:28:25 -0200
commit79100b8a3a8057c5826dc064fea91b73f0080b4c (patch)
treec6e0e8c905d1c779d064c34a4c1a9f7769272642 /actionview/lib/action_view/helpers/tags/translator.rb
parent96be4f65d0f68ae948f5665bc09bd3c69955be89 (diff)
downloadrails-79100b8a3a8057c5826dc064fea91b73f0080b4c.tar.gz
rails-79100b8a3a8057c5826dc064fea91b73f0080b4c.tar.bz2
rails-79100b8a3a8057c5826dc064fea91b73f0080b4c.zip
Only check if object respond_to to_model once
Diffstat (limited to 'actionview/lib/action_view/helpers/tags/translator.rb')
-rw-r--r--actionview/lib/action_view/helpers/tags/translator.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/actionview/lib/action_view/helpers/tags/translator.rb b/actionview/lib/action_view/helpers/tags/translator.rb
index 9cdccaf4aa..42433caf36 100644
--- a/actionview/lib/action_view/helpers/tags/translator.rb
+++ b/actionview/lib/action_view/helpers/tags/translator.rb
@@ -2,13 +2,13 @@ module ActionView
module Helpers
module Tags # :nodoc:
class Translator # :nodoc:
- attr_reader :object, :object_name, :method_and_value, :i18n_scope
+ attr_reader :object_name, :method_and_value, :i18n_scope, :model
def initialize(object, object_name, method_and_value, i18n_scope)
- @object = object
@object_name = object_name.gsub(/\[(.*)_attributes\]\[\d+\]/, '.\1')
@method_and_value = method_and_value
@i18n_scope = i18n_scope
+ @model = object.respond_to?(:to_model) ? object.to_model : object
end
def call
@@ -30,10 +30,6 @@ module ActionView
model.class.human_attribute_name(method_and_value)
end
end
-
- def model
- @model ||= object.to_model if object.respond_to?(:to_model)
- end
end
end
end