Sha256: e4eef0817b5b8812c65aba821fd453b18cd3fb74c35b3a26524d321d77dcaef7

Contents?: true

Size: 920 Bytes

Versions: 4

Compression:

Stored size: 920 Bytes

Contents

module SocialNetworking
  # Sends sms or emails to participants.
  class Notification
    include Sms
    attr_reader :current_participant,
                :mailer,
                :recipient,
                :message_body,
                :subject

    def initialize(
      current_participant:,
      mailer:,
      recipient:,
      message_body:,
      subject:)
      @current_participant = current_participant
      @mailer = mailer
      @message_body = message_body
      @recipient = recipient
      @subject = subject
    end

    def notify
      return if current_participant == recipient
      if recipient.contact_preference == "email"
        send_email
      else
        send_sms(recipient, message_body)
      end
    end

    def send_email
      mailer
        .notify(
          recipient: recipient,
          body: message_body,
          subject: subject)
        .deliver_now
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
social_networking-0.11.1 app/models/social_networking/notification.rb
social_networking-0.11.0 app/models/social_networking/notification.rb
social_networking-0.10.0 app/models/social_networking/notification.rb
social_networking-0.9.3 app/models/social_networking/notification.rb