Class: GRPC::InterceptionContext
- Inherits:
-
Object
- Object
- GRPC::InterceptionContext
- Defined in:
- src/ruby/lib/grpc/generic/interceptors.rb
Overview
Represents the context in which an interceptor runs. Used to provide an injectable mechanism for handling interception. This is an EXPERIMENTAL API.
Instance Method Summary collapse
-
#initialize(interceptors = []) ⇒ InterceptionContext
constructor
A new instance of InterceptionContext.
-
#intercept!(type, args = {}) ⇒ Object
Intercept the call and fire out to interceptors in a FIFO execution.
Constructor Details
#initialize(interceptors = []) ⇒ InterceptionContext
Returns a new instance of InterceptionContext.
158 159 160 |
# File 'src/ruby/lib/grpc/generic/interceptors.rb', line 158 def initialize(interceptors = []) @interceptors = interceptors.dup end |
Instance Method Details
#intercept!(type, args = {}) ⇒ Object
Intercept the call and fire out to interceptors in a FIFO execution. This is an EXPERIMENTAL API.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'src/ruby/lib/grpc/generic/interceptors.rb', line 169 def intercept!(type, args = {}) return yield if @interceptors.none? i = @interceptors.pop return yield unless i i.send(type, **args) do if @interceptors.any? intercept!(type, args) do yield end else yield end end end |