Class: Telegram::Bot::Middleware
- Inherits:
-
Object
- Object
- Telegram::Bot::Middleware
- Defined in:
- lib/telegram/bot/middleware.rb
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(bot, controller) ⇒ Middleware
constructor
A new instance of Middleware.
- #inspect ⇒ Object
Constructor Details
#initialize(bot, controller) ⇒ Middleware
Returns a new instance of Middleware.
11 12 13 14 |
# File 'lib/telegram/bot/middleware.rb', line 11 def initialize(bot, controller) @bot = bot @controller = controller end |
Instance Attribute Details
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
9 10 11 |
# File 'lib/telegram/bot/middleware.rb', line 9 def bot @bot end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
9 10 11 |
# File 'lib/telegram/bot/middleware.rb', line 9 def controller @controller end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/telegram/bot/middleware.rb', line 16 def call(env) request = ActionDispatch::Request.new(env) update = request.request_parameters controller.dispatch(bot, update) [200, {}, ['']] end |
#inspect ⇒ Object
23 24 25 |
# File 'lib/telegram/bot/middleware.rb', line 23 def inspect "#<#{self.class.name}(#{controller.try!(:name)})>" end |