зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-08-28 15:26:18 +03:00
* Update rubopcop [WIP] * Further rubocop fixes * Fix rubocop-rails cops * Fix spec * Disable rubocop suggestions * Run rubocop in github actions rather than in codeclimate
39 строки
1.1 KiB
Ruby
39 строки
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Telegram
|
|
module Bot
|
|
class UpdatesController
|
|
module Testing
|
|
IVARS_TO_KEEP = %i[@_session].freeze
|
|
|
|
# Perform multiple dispatches on same instance.
|
|
def dispatch_again(bot = nil, update = nil, webhook_request = nil)
|
|
recycle!
|
|
initialize(bot, update, webhook_request)
|
|
dispatch
|
|
end
|
|
|
|
# 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.
|
|
def recycle!(full = false) # rubocop:disable Style/OptionalBooleanParameter
|
|
return unless full
|
|
(instance_variables - IVARS_TO_KEEP).each do |ivar|
|
|
remove_instance_variable(ivar)
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
# Stubs session.
|
|
def session
|
|
@_session ||= # rubocop:disable Naming/MemoizedInstanceVariableName
|
|
Session::NullSessionHash.new
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|