Class: Mack::Notifier::Adapters::Xmpp

Inherits:
Base show all
Includes:
Jabber
Defined in:
lib/mack-notifier/adapters/xmpp_msg.rb

Overview

All mail adapters need to extend this class.

Constant Summary

Constants included from Jabber

Jabber::XMPP4R_VERSION

Instance Attribute Summary

Attributes inherited from Base

#mack_notifier

Instance Method Summary collapse

Methods included from Jabber

debug, debug=, debuglog, logger, logger=

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Mack::Notifier::Adapters::Base

Instance Method Details

#convertObject

Convert the Mack::Notifier object to the adapted object.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mack-notifier/adapters/xmpp_msg.rb', line 30

def convert
  settings = configatron.mack.notifier.xmpp_settings
  arr = [mack_notifier.to].flatten
  @xmpp_container = XmppMsgContainer.new
  @xmpp_container.recipients = arr
  
  arr.each do |rcpt|
    xmpp_msg = Message::new
    xmpp_msg.set_type(:normal)
    xmpp_msg.set_to(rcpt)
    xmpp_msg.set_from(mack_notifier.from)
    xmpp_msg.set_subject(mack_notifier.subject)
    xmpp_msg.set_type(settings.message_type)
    unless mack_notifier.body(:plain).blank?
      xmpp_msg.set_body(mack_notifier.body(:plain))
    end

    @xmpp_container.messages << xmpp_msg
  end
  
  return @xmpp_container
end

#deliverableObject

The RAW encoded String ready for delivery via SMTP, Sendmail, etc…



54
55
56
# File 'lib/mack-notifier/adapters/xmpp_msg.rb', line 54

def deliverable
  return @xmpp_container
end

#transformedObject

The transformed (ie, converted, object)



24
25
26
27
# File 'lib/mack-notifier/adapters/xmpp_msg.rb', line 24

def transformed
  raise Mack::Errors::UnconvertedNotifier.new if @xmpp_msg.nil?
  return @xmpp_container
end