Files
nairobi/lib/evaluation_comment_email.rb
Javi Martín d0d681a44b Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00

34 lines
580 B
Ruby

class EvaluationCommentEmail
attr_reader :comment
def initialize(comment)
@comment = comment
end
def commentable
comment.commentable
end
def to
@to ||= related_users
end
def subject
I18n.t("mailers.evaluation_comment.subject")
end
def can_be_sent?
commentable.present? && to.any?
end
private
def related_users
return [] if comment.commentable.nil?
comment.commentable
.admin_and_valuator_users_associated
.reject { |associated_user| associated_user.user == comment.author }
end
end