Module: Telegram::Bot::UpdatesController::Testing

Defined in:
lib/telegram/bot/updates_controller/testing.rb

Constant Summary collapse

IVARS_TO_KEEP =
%i[@_session].freeze

Instance Method Summary collapse

Instance Method Details

#dispatch_again(bot = nil, update = nil, webhook_request = nil) ⇒ Object

Perform multiple dispatches on same instance.



8
9
10
11
12
# File 'lib/telegram/bot/updates_controller/testing.rb', line 8

def dispatch_again(bot = nil, update = nil, webhook_request = nil)
  recycle!
  initialize(bot, update, webhook_request)
  dispatch
end

#recycle!(full = false) ⇒ Object

Cleans controller between dispatches. Seems like there is nothing to clean between requests for now: everything will be rewriten with #initialize.

With ‘full` set to `true` it’ll clear all cached instance variables.



19
20
21
22
23
24
# File 'lib/telegram/bot/updates_controller/testing.rb', line 19

def recycle!(full = false)
  return unless full
  (instance_variables - IVARS_TO_KEEP).each do |ivar|
    remove_instance_variable(ivar)
  end
end