Class: ReplySerializer

Inherits:
ActiveModel::Serializer
  • Object
show all
Defined in:
app/serializers/reply_serializer.rb

Instance Method Summary collapse

Instance Method Details

#repliesObject



12
13
14
15
16
17
18
# File 'app/serializers/reply_serializer.rb', line 12

def replies
  if object.reply_id
    []
  else
    object.replies.map{|r| ReplySerializer.new(r)}
  end
end

#user_nameObject



8
9
10
# File 'app/serializers/reply_serializer.rb', line 8

def user_name
  object.user.try(:name)
end

#user_slugObject



4
5
6
# File 'app/serializers/reply_serializer.rb', line 4

def user_slug
  object.user.try(:slug)
end