discourse/app/serializers/reviewable_explanation_serializer.rb
Krzysztof Kotlarek 427d54b2b0 DEV: Upgrading Discourse to Zeitwerk (#8098)
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. 

We no longer need to use Rails "require_dependency" anywhere and instead can just use standard 
Ruby patterns to require files.

This is a far reaching change and we expect some followups here.
2019-10-02 14:01:53 +10:00

38 lines
650 B
Ruby

# frozen_string_literal: true
class ReviewableExplanationSerializer < ApplicationSerializer
attributes(
:id,
:total_score,
:scores,
:min_score_visibility,
:hide_post_score
)
has_many :scores, serializer: ReviewableScoreExplanationSerializer, embed: :objects
def id
object[:reviewable].id
end
def hide_post_score
Reviewable.score_required_to_hide_post
end
def spam_silence_score
Reviewable.spam_score_to_silence_new_user
end
def min_score_visibility
Reviewable.min_score_for_priority
end
def total_score
object[:reviewable].score
end
def scores
object[:scores]
end
end