Class: Copland::InterceptorChainBuilder::InterceptorChainElement
- Inherits:
-
Object
- Object
- Copland::InterceptorChainBuilder::InterceptorChainElement
- Defined in:
- lib/copland/interceptor-chain.rb
Overview
A single element in an interceptor chain. Each interceptor object is wrapped in an instance of one of these. Calling #process_next on a given chain element, invokes the #process method on the corresponding interceptor, with the next element in the chain being passed in.
Instance Method Summary collapse
-
#initialize(interceptor) ⇒ InterceptorChainElement
constructor
Create a new InterceptorChainElement that wraps the given interceptor.
-
#next=(next_obj) ⇒ Object
Set the next element in the interceptor chain to the given object.
-
#process_next(context) ⇒ Object
Invokes the #process method of the interceptor encapsulated by this object, with the next element in the chain being passed to it.
Constructor Details
#initialize(interceptor) ⇒ InterceptorChainElement
Create a new InterceptorChainElement that wraps the given interceptor.
56 57 58 |
# File 'lib/copland/interceptor-chain.rb', line 56 def initialize( interceptor ) @interceptor = interceptor end |
Instance Method Details
#next=(next_obj) ⇒ Object
Set the next element in the interceptor chain to the given object. This must be either an InterceptorChainElement instance of a ProxyObjectChainElement instance.
63 64 65 |
# File 'lib/copland/interceptor-chain.rb', line 63 def next=( next_obj ) @next_obj = next_obj end |
#process_next(context) ⇒ Object
Invokes the #process method of the interceptor encapsulated by this object, with the next element in the chain being passed to it.
69 70 71 72 73 74 75 |
# File 'lib/copland/interceptor-chain.rb', line 69 def process_next( context ) if @next_obj.nil? raise CoplandError, "[BUG] interceptor chain should always terminate with proxy" end @interceptor.process( @next_obj, context ) end |