Sha256: 7354b65b34fbafcabcc7d1932d2cbd12dbc2715ce85b49cc768e3b2543a5f57c

Contents?: true

Size: 936 Bytes

Versions: 16

Compression:

Stored size: 936 Bytes

Contents

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)
          recycle!
          initialize(bot, update)
          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)
          return unless full
          (instance_variables - IVARS_TO_KEEP).each do |ivar|
            remove_instance_variable(ivar)
          end
        end

        protected

        # Stubs session.
        def session
          @_session ||= Session::NullSessionHash.new
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
telegram-bot-0.15.7 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.15.6 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.15.4 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.15.3 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.15.2 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.15.1 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.15.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.14.4 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.14.3 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.14.2 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.14.1 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.14.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.13.1 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.13.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.12.4 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.12.3 lib/telegram/bot/updates_controller/testing.rb