Extract methods to get recipients and valid segments
This way we don't have to use the `send` method in other places, like the AdminNotification class, and we can change the internal implementation at any point.
This commit is contained in:
@@ -57,8 +57,16 @@ class UserSegments
|
||||
)
|
||||
end
|
||||
|
||||
def self.valid_segment?(segment)
|
||||
segment && respond_to?(segment)
|
||||
end
|
||||
|
||||
def self.recipients(segment)
|
||||
send(segment)
|
||||
end
|
||||
|
||||
def self.user_segment_emails(segment)
|
||||
UserSegments.send(segment).newsletter.order(:created_at).pluck(:email).compact
|
||||
recipients(segment).newsletter.order(:created_at).pluck(:email).compact
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user