Class: BasicCategorySerializer

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

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Instance Method Details

#can_editObject



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

def can_edit
  true
end

#custom_fieldsObject



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

def custom_fields
  object.preloaded_custom_fields
end

#descriptionObject



61
62
63
64
65
66
67
# File 'app/serializers/basic_category_serializer.rb', line 61

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

#description_excerptObject



69
70
71
72
73
74
75
# File 'app/serializers/basic_category_serializer.rb', line 69

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

#description_textObject



53
54
55
56
57
58
59
# File 'app/serializers/basic_category_serializer.rb', line 53

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

#include_can_edit?Boolean

Returns:

  • (Boolean)


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

def include_can_edit?
  scope && scope.can_edit?(object)
end

#include_custom_fields?Boolean

Returns:

  • (Boolean)


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

def include_custom_fields?
  custom_fields.present?
end

#include_parent_category_id?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/serializers/basic_category_serializer.rb', line 41

def include_parent_category_id?
  parent_category_id
end

#nameObject



45
46
47
48
49
50
51
# File 'app/serializers/basic_category_serializer.rb', line 45

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

#notification_levelObject



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

def notification_level
  object.notification_level
end