Class: Nuntius::BaseMessageBox
- Inherits:
-
Object
- Object
- Nuntius::BaseMessageBox
- Defined in:
- app/message_boxes/nuntius/base_message_box.rb
Overview
Message boxes process inbound messages
Class Attribute Summary collapse
-
.routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
- .deliver(message) ⇒ Object
- .message_box_for(transport: nil, provider: nil) ⇒ Object
- .provider(value = nil) ⇒ Object
- .route(attribute = :to, test = /.*/, to:) ⇒ Object
-
.settings(hash = nil) ⇒ Object
Defines the settings.
- .transport(value = nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(message) ⇒ BaseMessageBox
constructor
A new instance of BaseMessageBox.
-
#mail ⇒ Mail::Message
In case of mail transport mail will return the mail itself, using github.com/mikel/mail For other transports it will return nil.
Constructor Details
#initialize(message) ⇒ BaseMessageBox
Returns a new instance of BaseMessageBox.
10 11 12 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 10 def initialize() @message = end |
Class Attribute Details
.routes ⇒ Object (readonly)
Returns the value of attribute routes.
25 26 27 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 25 def routes @routes end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 8 def @message end |
Class Method Details
.deliver(message) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 49 def deliver() klasses = (transport: .transport.to_sym, provider: .provider.to_sym) klass, method = (klasses, ) if method klass.new().send(method) true end end |
.message_box_for(transport: nil, provider: nil) ⇒ Object
59 60 61 62 63 64 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 59 def (transport: nil, provider: nil) result = descendants result = result.select { || .transport == transport } if transport result = result.select { || .provider == provider } if provider result end |
.provider(value = nil) ⇒ Object
27 28 29 30 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 27 def provider(value = nil) @provider = value.to_sym if value @provider end |
.route(attribute = :to, test = /.*/, to:) ⇒ Object
37 38 39 40 41 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 37 def route(attribute = :to, test = /.*/, to:) @routes ||= {} @routes[attribute] = {test: test, to: to} @routes end |
.settings(hash = nil) ⇒ Object
Defines the settings
44 45 46 47 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 44 def settings(hash = nil) @settings = hash if hash @settings end |
.transport(value = nil) ⇒ Object
32 33 34 35 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 32 def transport(value = nil) @transport = value.to_sym if value @transport end |
Instance Method Details
#mail ⇒ Mail::Message
In case of mail transport mail will return the mail itself, using github.com/mikel/mail For other transports it will return nil.
17 18 19 20 21 22 |
# File 'app/message_boxes/nuntius/base_message_box.rb', line 17 def mail return nil unless self.class.transport.to_sym == :mail return @mail if @mail @mail = Mail.new(..download) end |