Class: Astrotrain::Mapping::Transport
- Inherits:
-
Object
- Object
- Astrotrain::Mapping::Transport
- Defined in:
- lib/astrotrain/mapping/transport.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.processing ⇒ Object
Returns the value of attribute processing.
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
-
.inherited(child) ⇒ Object
defines custom #process class methods that instantiate the class and calls a #process instance method.
-
.process(message, mapping, recipient) ⇒ Object
process a given message against the mapping.
Instance Method Summary collapse
- #fields ⇒ Object
-
#initialize(message, mapping, recipient) ⇒ Transport
constructor
A new instance of Transport.
- #process ⇒ Object
Constructor Details
#initialize(message, mapping, recipient) ⇒ Transport
Returns a new instance of Transport.
22 23 24 25 26 27 |
# File 'lib/astrotrain/mapping/transport.rb', line 22 def initialize(, mapping, recipient) .body = mapping.find_reply_from(.body) @message = @mapping = mapping @recipient = recipient end |
Class Attribute Details
.processing ⇒ Object
Returns the value of attribute processing.
5 6 7 |
# File 'lib/astrotrain/mapping/transport.rb', line 5 def processing @processing end |
Instance Attribute Details
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
11 12 13 |
# File 'lib/astrotrain/mapping/transport.rb', line 11 def mapping @mapping end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'lib/astrotrain/mapping/transport.rb', line 11 def @message end |
Class Method Details
.inherited(child) ⇒ Object
defines custom #process class methods that instantiate the class and calls a #process instance method
45 46 47 48 49 50 51 52 |
# File 'lib/astrotrain/mapping/transport.rb', line 45 def self.inherited(child) super class << child def process(, mapping, recipient) new(, mapping, recipient).process end end end |
.process(message, mapping, recipient) ⇒ Object
process a given message against the mapping. The mapping transport is checked, and the appropirate transport class handles the request.
15 16 17 18 19 20 |
# File 'lib/astrotrain/mapping/transport.rb', line 15 def self.process(, mapping, recipient) case mapping.transport when 'http_post' then HttpPost.process(, mapping, recipient) when 'jabber' then Jabber.process(, mapping, recipient) end end |
Instance Method Details
#fields ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/astrotrain/mapping/transport.rb', line 33 def fields @fields ||= begin all_emails = @message.recipients - [@recipient] f = {:subject => @message.subject, :to => @recipient, :from => @message.sender, :body => @message.body, :emails => all_emails, :html => @message.html} @message.headers.each do |key, value| f["headers[#{key}]"] = value end f end end |
#process ⇒ Object
29 30 31 |
# File 'lib/astrotrain/mapping/transport.rb', line 29 def process raise UnimplementedError end |