Class: SocialNetworking::Serializers::GoalSerializer

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

Overview

Serializes Goal 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
# File 'app/models/social_networking/serializers/goal_serializer.rb', line 6

def to_serialized
  {
    className: "SocialNetworking::Goal",
    id: model.id,
    createdAt: model.created_at,
    participantId: model.participant_id,
    isAdmin: model.participant.is_admin,
    summary: "#{model.participant_id} set the goal " \
             "#{model.description}",
    description: model.description,
    isCompleted: model.is_completed,
    isDeleted: model.is_deleted,
    dueOn: model.due_on ? model.due_on.to_s(:participant_date) : "",
    comments: CommentSerializer.from_collection(model.comments)
  }
end