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



75
76
77
# File 'app/serializers/basic_category_serializer.rb', line 75

def can_edit
  true
end

#custom_fieldsObject



87
88
89
# File 'app/serializers/basic_category_serializer.rb', line 87

def custom_fields
  object.preloaded_custom_fields
end

#descriptionObject



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

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

#description_excerptObject



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

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

#description_textObject



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

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)


79
80
81
# File 'app/serializers/basic_category_serializer.rb', line 79

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

#include_custom_fields?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'app/serializers/basic_category_serializer.rb', line 91

def include_custom_fields?
  custom_fields.present?
end

#include_parent_category_id?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/serializers/basic_category_serializer.rb', line 39

def include_parent_category_id?
  parent_category_id
end

#nameObject



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

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

#notification_levelObject



83
84
85
# File 'app/serializers/basic_category_serializer.rb', line 83

def notification_level
  object.notification_level
end