Class: CategoryBadgeSerializer

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

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Instance Method Details

#description_textObject



18
19
20
21
22
23
24
# File 'app/serializers/category_badge_serializer.rb', line 18

def description_text
  if object.uncategorized?
    I18n.t("category.uncategorized_description", locale: SiteSetting.default_locale)
  else
    object.description_text
  end
end

#include_parent_category_id?Boolean

Returns:

  • (Boolean)


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

def include_parent_category_id?
  parent_category_id.present?
end

#nameObject



10
11
12
13
14
15
16
# File 'app/serializers/category_badge_serializer.rb', line 10

def name
  if object.uncategorized?
    I18n.t("uncategorized_category_name", locale: SiteSetting.default_locale)
  else
    object.name
  end
end