Class: TorqueBox::Messaging::ProcessorMiddleware::Chain
- Inherits:
-
Object
- Object
- TorqueBox::Messaging::ProcessorMiddleware::Chain
- Defined in:
- lib/torquebox/messaging/processor_middleware/chain.rb
Instance Method Summary collapse
- #append(klass, *args) ⇒ Object (also: #add)
- #inspect ⇒ Object
- #invoke(session, message, processor) ⇒ Object
- #prepend(klass, *args) ⇒ Object
- #remove(klass) ⇒ Object
Instance Method Details
#append(klass, *args) ⇒ Object Also known as: add
28 29 30 31 |
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 28 def append(klass, *args) chain << MWare.new(klass, args) unless locate(klass) self end |
#inspect ⇒ Object
41 42 43 |
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 41 def inspect chain.map(&:klass).inspect end |
#invoke(session, message, processor) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 45 def invoke(session, , processor) realized_chain = realize walker = lambda do mware = realized_chain.shift if mware mware.call(session, , &walker) else processor.process!() end end walker.call end |
#prepend(klass, *args) ⇒ Object
23 24 25 26 |
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 23 def prepend(klass, *args) chain.unshift(MWare.new(klass, args)) unless locate(klass) self end |
#remove(klass) ⇒ Object
35 36 37 38 39 |
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 35 def remove(klass) loc = locate(klass) chain.delete_at(loc) if loc self end |