Class: BBK::App::Middlewares::FromBlock

Inherits:
Base
  • Object
show all
Defined in:
lib/bbk/app/middlewares/from_block.rb

Instance Attribute Summary

Attributes inherited from Base

#app

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ FromBlock

Returns a new instance of FromBlock.

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/bbk/app/middlewares/from_block.rb', line 6

def initialize(&block)
  raise ArgumentError.new('Not passed block') unless block_given?

  @block = block
end

Instance Method Details

#build(app) ⇒ Object



12
13
14
15
# File 'lib/bbk/app/middlewares/from_block.rb', line 12

def build(app)
  @app = app
  self
end

#call(msg) ⇒ Object



17
18
19
# File 'lib/bbk/app/middlewares/from_block.rb', line 17

def call(msg)
  @block.call(app, msg)
end