Class: SocialNetworking::Serializers::NudgeSerializer

Inherits:
Serializer
  • Object
show all
Defined in:
app/models/social_networking/serializers/nudge_serializer.rb

Overview

Serializes Nudge models.

Instance Attribute Summary

Attributes inherited from Serializer

#model

Instance Method Summary collapse

Methods inherited from Serializer

from_collection, #initialize

Constructor Details

This class inherits a constructor from SocialNetworking::Serializers::Serializer

Instance Method Details

#to_serializedObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/social_networking/serializers/nudge_serializer.rb', line 6

def to_serialized
  recipient_profile = Profile.find_by_participant_id(model.recipient_id)

  {
    className: "SocialNetworking::Nudge",
    id: model.id,
    participantId: model.initiator_id,
    isAdmin: model.initiator.is_admin,
    createdAt: model.created_at,
    createdAtRaw: model.created_at.to_i,
    initiatorId: model.initiator_id,
    recipientId: model.recipient_id,
    summary: "nudged #{recipient_profile.user_name}",
    description: "nudge",
    comments: CommentSerializer.from_collection(model.comments)
  }
end