Sha256: fcac46066f09573007238c58867a4f554dc263f032669c71fa402843c923e3e7

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.12.1 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.12.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.11.3 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.11.2 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.11.1 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.11.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.10.2 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.10.1 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.10.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.9.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.9.0.alpha2 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.9.0.alpha1 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.8.0 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.7.4 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.7.3 lib/telegram/bot/updates_controller/testing.rb
telegram-bot-0.7.2 lib/telegram/bot/updates_controller/testing.rb