Class: SocialNetworking::Serializers::ProfileSerializer

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

Overview

Serializes Profile models.

Constant Summary collapse

DEFAULT_ICON =
"questionmark"

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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/social_networking/serializers/profile_serializer.rb', line 8

def to_serialized
  if model.participant.is_admin
    icon_path = "social_networking/_profile_icon_admin.png"
  else
    icon_path = "social_networking/profile_icon_" +
                (model.icon_name || DEFAULT_ICON) + ".png"
  end
  {
    id: model.id,
    participantId: model.participant_id,
    username: model.user_name,
    latestAction: model.latest_action_at,
    endOfTrial: model.active_membership_end_date,
    isAdmin: model.participant.is_admin,
    isWoz: woz? && model.participant.is_admin,
    iconSrc: ApplicationController.helpers.asset_path(icon_path)
  }
end