Class: GroupShowSerializer

Inherits:
BasicGroupSerializer show all
Defined in:
app/serializers/group_show_serializer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicGroupSerializer

#bio_excerpt, #can_admin_group, #can_edit_group, #can_see_members, #display_name, #include_bio_raw?, #include_can_admin_group?, #include_can_edit_group?, #include_display_name?, #include_has_messages?, #include_incoming_email?

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Class Method Details

.admin_attributes(*attrs) ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/serializers/group_show_serializer.rb', line 12

def self.admin_attributes(*attrs)
  attributes(*attrs)
  attrs.each do |attr|
    define_method "include_#{attr}?" do
      scope.is_admin?
    end
  end
end

.admin_or_owner_attributes(*attrs) ⇒ Object



49
50
51
52
53
54
55
56
# File 'app/serializers/group_show_serializer.rb', line 49

def self.admin_or_owner_attributes(*attrs)
  attributes(*attrs)
  attrs.each do |attr|
    define_method "include_#{attr}?" do
      scope.is_admin? || (include_is_group_owner? && is_group_owner)
    end
  end
end

Instance Method Details

#associated_group_idsObject



129
130
131
# File 'app/serializers/group_show_serializer.rb', line 129

def associated_group_ids
  object.associated_groups.map(&:id)
end

#include_associated_group_ids?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'app/serializers/group_show_serializer.rb', line 133

def include_associated_group_ids?
  scope.can_associate_groups?
end

#include_flair_icon?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'app/serializers/group_show_serializer.rb', line 109

def include_flair_icon?
  flair_icon.present? && (is_group_owner || scope.is_admin?)
end

#include_flair_type?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'app/serializers/group_show_serializer.rb', line 113

def include_flair_type?
  flair_type.present? && (is_group_owner || scope.is_admin?)
end

#include_is_group_owner?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'app/serializers/group_show_serializer.rb', line 77

def include_is_group_owner?
  authenticated? && fetch_group_user&.owner
end

#include_is_group_owner_display?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'app/serializers/group_show_serializer.rb', line 85

def include_is_group_owner_display?
  authenticated?
end

#include_is_group_user?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'app/serializers/group_show_serializer.rb', line 69

def include_is_group_user?
  authenticated?
end

#include_mentionable?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'app/serializers/group_show_serializer.rb', line 93

def include_mentionable?
  authenticated?
end

#include_messageable?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'app/serializers/group_show_serializer.rb', line 97

def include_messageable?
  authenticated?
end

#is_group_ownerObject



81
82
83
# File 'app/serializers/group_show_serializer.rb', line 81

def is_group_owner
  true
end

#is_group_owner_displayObject



89
90
91
# File 'app/serializers/group_show_serializer.rb', line 89

def is_group_owner_display
  !!fetch_group_user&.owner
end

#is_group_userObject



73
74
75
# File 'app/serializers/group_show_serializer.rb', line 73

def is_group_user
  !!fetch_group_user
end

#mentionableObject



101
102
103
# File 'app/serializers/group_show_serializer.rb', line 101

def mentionable
  Group.mentionable(scope.user).exists?(id: object.id)
end

#messageableObject



105
106
107
# File 'app/serializers/group_show_serializer.rb', line 105

def messageable
  scope.can_send_private_message?(object)
end