lib/telegram/bot/async.rb in telegram-bot-0.16.1 vs lib/telegram/bot/async.rb in telegram-bot-0.16.3

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Telegram module Bot # Telegram clients can perform requests in async way with # any job adapter (ActiveJob by default). Using Rails you don't need any # additional configuration. However you may want to enable async requests @@ -126,19 +128,19 @@ # Sets async value in a thread-safe way for the block. # Uses `self.class.prepare_async_val` to prepare value. # # If no block is given returns previously set value or the global one, # set by #async=. - def async(val = true) + def async(val = true) # rubocop:disable Style/OptionalBooleanParameter thread_key = object_id thread_store = Async.thread_store return thread_store.fetch(thread_key) { @async } unless block_given? begin old_val = thread_store.fetch(thread_key) { MISSING_VALUE } thread_store[thread_key] = self.class.prepare_async_val(val) yield ensure - if MISSING_VALUE == old_val + if old_val == MISSING_VALUE thread_store.delete(thread_key) else thread_store[thread_key] = old_val end end