Sha256: b18cbc1ff8d5b035d4951cd9bfb31b9519c5b91fa5e5770efe7b3dbb55d8b7d7

Contents?: true

Size: 410 Bytes

Versions: 1

Compression:

Stored size: 410 Bytes

Contents

class ReplySerializer < ActiveModel::Serializer
  attributes :id, :reply_id, :user_id, :user_slug, :user_name, :text, :positive, :likes_count, :dislikes_count, :created_at, :replies

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

  def user_name
    object.user.try(:name)
  end
  
  def replies
    if object.reply_id
      []
    else
      object.replies.map{|r| ReplySerializer.new(r)}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voluntary_feedback-0.1.0 app/serializers/reply_serializer.rb