Sha256: a3439e5bfc96f63308237fd93b6dbf75135ceee1fc331549a074825965a134d8

Contents?: true

Size: 468 Bytes

Versions: 5

Compression:

Stored size: 468 Bytes

Contents

class ArgumentSerializer < ActiveModel::Serializer
  attributes :id, :vote, :topic_id, :topic_name, :argumentable_type, :argumentable_id, :argumentable_name, :value, :user_id, :user_name, :user_slug, :positive, :likes_count, :dislikes_count

  def argumentable_name
    object.argumentable.try(:name)
  end
  
  def topic_name
    object.topic.try(:name)
  end
  
  def user_name
    object.user.try(:name)
  end
  
  def user_slug
    object.user.try(:slug)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
voluntary-0.7.1 app/serializers/argument_serializer.rb
voluntary-0.7.0 app/serializers/argument_serializer.rb
voluntary-0.6.0 app/serializers/argument_serializer.rb
voluntary-0.5.2 app/serializers/argument_serializer.rb
voluntary-0.5.1 app/serializers/argument_serializer.rb