Class: TagGroupSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/tag_group_serializer.rb

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Instance Method Details

#parent_tag_nameObject



10
11
12
# File 'app/serializers/tag_group_serializer.rb', line 10

def parent_tag_name
  [object.parent_tag.try(:name)].compact
end

#permissionsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/serializers/tag_group_serializer.rb', line 14

def permissions
  @permissions ||=
    begin
      h = {}

      object
        .tag_group_permissions
        .joins(:group)
        .includes(:group)
        .find_each do |tgp|
          name = Group::AUTO_GROUP_IDS.fetch(tgp.group_id, tgp.group.name).to_s
          h[name] = tgp.permission_type
        end

      h["everyone"] = TagGroupPermission.permission_types[:full] if h.empty?

      h
    end
end

#tag_namesObject



6
7
8
# File 'app/serializers/tag_group_serializer.rb', line 6

def tag_names
  object.tags.base_tags.map(&:name).sort
end