Class: Telegram::Bot::Middleware

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bot, controller) ⇒ Middleware

Returns a new instance of Middleware.



13
14
15
16
# File 'lib/telegram/bot/middleware.rb', line 13

def initialize(bot, controller)
  @bot = bot
  @controller = controller
end

Instance Attribute Details

#botObject (readonly)

Returns the value of attribute bot.



11
12
13
# File 'lib/telegram/bot/middleware.rb', line 11

def bot
  @bot
end

#controllerObject (readonly)

Returns the value of attribute controller.



11
12
13
# File 'lib/telegram/bot/middleware.rb', line 11

def controller
  @controller
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  request = ActionDispatch::Request.new(env)
  update = request.request_parameters
  controller.dispatch(bot, update, request)
  [200, {}, ['']]
end

#inspectObject



25
26
27
# File 'lib/telegram/bot/middleware.rb', line 25

def inspect
  "#<#{self.class.name}(#{controller&.name})>"
end