PERF: avoid needless :try invokes respond_to? etc

This commit is contained in:
Sam 2015-10-02 15:00:00 +10:00
parent 6246dd0aa2
commit 43345063b9
2 changed files with 4 additions and 4 deletions

View file

@ -9,15 +9,15 @@ class BasicPostSerializer < ApplicationSerializer
:cooked_hidden
def name
object.user.try(:name)
object.user && object.user.name
end
def username
object.user.try(:username)
object.user && object.user.username
end
def avatar_template
object.user.try(:avatar_template)
object.user && object.user.avatar_template
end
def cooked_hidden

View file

@ -74,7 +74,7 @@ class PostSerializer < BasicPostSerializer
end
def topic_slug
object.try(:topic).try(:slug)
object.topic && object.topic.slug
end
def include_topic_title?