Class: TorqueBox::Messaging::ProcessorMiddleware::Chain Private

Inherits:
Object
  • Object
show all
Defined in:
lib/torquebox/messaging/processor_middleware/chain.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#append(klass, *args) ⇒ Object Also known as: add

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 29

def append(klass, *args)
  chain << MWare.new(klass, args) unless locate(klass)
  self
end

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 42

def inspect
  chain.map(&:klass).inspect
end

#invoke(session, message, processor) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 46

def invoke(session, message, processor)
  realized_chain = realize
  walker = lambda do
    mware = realized_chain.shift
    if mware
      mware.call(session, message, &walker)
    else
      processor.process!(message)
    end
  end
  walker.call
end

#prepend(klass, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 24

def prepend(klass, *args)
  chain.unshift(MWare.new(klass, args)) unless locate(klass)
  self
end

#remove(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
39
40
# File 'lib/torquebox/messaging/processor_middleware/chain.rb', line 36

def remove(klass)
  loc = locate(klass)
  chain.delete_at(loc) if loc
  self
end