Class: Thrift::Middleware::MultiMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/thrift/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(middlewares) ⇒ MultiMiddleware

Returns a new instance of MultiMiddleware.



14
15
16
# File 'lib/thrift/middleware.rb', line 14

def initialize(middlewares)
  @middlewares = middlewares
end

Instance Method Details

#handle_binary(mth, args = {}, &block) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/thrift/middleware.rb', line 26

def handle_binary(mth, args = {}, &block)
  @middlewares.reverse.reduce(block) do |acc, m|
    Proc.new do |args|
      m.handle_binary(mth, args) { |args| acc.call(args) }
    end
  end.call(args)
end

#handle_unary(mth, args = {}, &block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/thrift/middleware.rb', line 18

def handle_unary(mth, args = {}, &block)
  @middlewares.reverse.reduce(block) do |acc, m|
    Proc.new do |args|
      m.handle_unary(mth, args) { |args| acc.call(args) }
    end
  end.call(args)
end