This method was calling `check_availability`, which returned a boolean value and caused a `Naming/PredicateMethod` when upgrading rubocop. So we're changing the logic a little bit to remove the `check_availability` method and merge the tests of `check_availability` and `notifiable_available?` (which were almost identical) together.
40 lines
799 B
Ruby
40 lines
799 B
Ruby
module Notifiable
|
|
extend ActiveSupport::Concern
|
|
|
|
def notifiable_title
|
|
case self.class.name
|
|
when "ProposalNotification"
|
|
proposal.title
|
|
when "Comment"
|
|
commentable.title
|
|
else
|
|
title
|
|
end
|
|
end
|
|
|
|
def notifiable_body
|
|
body if attribute_names.include?("body")
|
|
end
|
|
|
|
def notifiable_available?
|
|
notifiable_resource.present? &&
|
|
!(notifiable_resource.respond_to?(:hidden?) && notifiable_resource.hidden?) &&
|
|
!(notifiable_resource.respond_to?(:retired?) && notifiable_resource.retired?)
|
|
end
|
|
|
|
def notifiable_resource
|
|
case self.class.name
|
|
when "ProposalNotification"
|
|
proposal
|
|
when "Comment"
|
|
commentable
|
|
else
|
|
self
|
|
end
|
|
end
|
|
|
|
def linkable_resource
|
|
is_a?(ProposalNotification) ? proposal : self
|
|
end
|
|
end
|