Class: BlabberMouth::Adapters::Xmpp

Inherits:
Base
  • Object
show all
Includes:
Jabber
Defined in:
lib/blabber_mouth/adapters/xmpp_msg.rb

Overview

All mail adapters need to extend this class.

Instance Attribute Summary

Attributes inherited from Base

#bm_notifier

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BlabberMouth::Adapters::Base

Instance Method Details

#convertObject

Convert the BlabberMouth object to the adapted object.



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

def convert
  settings = configatron.blabber_mouth.xmpp_settings
  arr = [bm_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(bm_notifier.from)
    xmpp_msg.set_subject(bm_notifier.subject)
    xmpp_msg.set_type(settings.message_type)
    unless bm_notifier.body(:plain).blank?
      xmpp_msg.set_body(bm_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…



53
54
55
# File 'lib/blabber_mouth/adapters/xmpp_msg.rb', line 53

def deliverable
  return @xmpp_container
end

#transformedObject

The transformed (ie, converted, object)



23
24
25
26
# File 'lib/blabber_mouth/adapters/xmpp_msg.rb', line 23

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