Class: CategoryDetailedSerializer
Instance Method Summary
collapse
#can_edit, #custom_fields, #description, #description_excerpt, #description_text, #include_can_edit?, #include_custom_fields?, #include_parent_category_id?, #name, #notification_level
expire_cache_fragment!, fragment_cache
#include!
Instance Method Details
#count_with_subcategories(method) ⇒ Object
57
58
59
60
61
62
63
|
# File 'app/serializers/category_detailed_serializer.rb', line 57
def count_with_subcategories(method)
count = object.public_send(method) || 0
object.subcategories.each { |category| count += (category.public_send(method) || 0) }
count
end
|
#include_displayable_topics? ⇒ Boolean
21
22
23
|
# File 'app/serializers/category_detailed_serializer.rb', line 21
def include_displayable_topics?
displayable_topics.present?
end
|
#include_is_uncategorized? ⇒ Boolean
33
34
35
|
# File 'app/serializers/category_detailed_serializer.rb', line 33
def include_is_uncategorized?
is_uncategorized
end
|
#include_subcategory_list? ⇒ Boolean
25
26
27
|
# File 'app/serializers/category_detailed_serializer.rb', line 25
def include_subcategory_list?
subcategory_list.present?
end
|
#is_uncategorized ⇒ Object
29
30
31
|
# File 'app/serializers/category_detailed_serializer.rb', line 29
def is_uncategorized
object.id == SiteSetting.uncategorized_category_id
end
|
#topics_all_time ⇒ Object
53
54
55
|
# File 'app/serializers/category_detailed_serializer.rb', line 53
def topics_all_time
count_with_subcategories(:topic_count)
end
|
#topics_day ⇒ Object
37
38
39
|
# File 'app/serializers/category_detailed_serializer.rb', line 37
def topics_day
count_with_subcategories(:topics_day)
end
|
#topics_month ⇒ Object
45
46
47
|
# File 'app/serializers/category_detailed_serializer.rb', line 45
def topics_month
count_with_subcategories(:topics_month)
end
|
#topics_week ⇒ Object
41
42
43
|
# File 'app/serializers/category_detailed_serializer.rb', line 41
def topics_week
count_with_subcategories(:topics_week)
end
|
#topics_year ⇒ Object
49
50
51
|
# File 'app/serializers/category_detailed_serializer.rb', line 49
def topics_year
count_with_subcategories(:topics_year)
end
|