Class: Api::UserSerializerWithPrivateFields

Inherits:
ActiveModel::Serializer
  • Object
show all
Includes:
RelationsSerializerHelper, RolesSerializerHelper, UtilsSerializerHelper
Defined in:
app/serializers/api/user_serializer_with_private_fields.rb

Instance Method Summary collapse

Methods included from UtilsSerializerHelper

#badges, #documents, #documents_feed, #feed_id, #geoloc, #get_feed_attachments, #interests, #ressources, #skills

Methods included from RolesSerializerHelper

#is_admin, #is_member, #is_owner, #is_pending, #is_reviewer

Methods included from RelationsSerializerHelper

#has_clapped, #has_followed, #has_saved

Instance Method Details

#mutual_countObject



48
49
50
51
52
53
54
# File 'app/serializers/api/user_serializer_with_private_fields.rb', line 48

def mutual_count
  if defined?(current_user).nil? || current_user.nil?
    0
  else
    object.follow_mutual_count(current_user)
  end
end

#scope?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/serializers/api/user_serializer_with_private_fields.rb', line 44

def scope?
  defined?(current_user).nil?
end

#statsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/serializers/api/user_serializer_with_private_fields.rb', line 56

def stats
  {
    saves_count: object.saves_count,
    claps_count: object.claps_count,
    followers_count: object.followers_count,
    following_count: object.following_count,
    mutual_count: mutual_count,
    projects_count: object.projects_count,
    needs_count: object.needs_count,
    workgroups_count: object.workgroups_count,
    challenges_count: object.challenges_count,
    programs_count: object.programs_count,
    spaces_count: object.spaces_count
  }
end