Sha256: 015b8803eabf243d1061f0c9b9c8cc2866d0566b28d610eeebe80a2297df6d73

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

class TD::UpdateHandler
  include Concurrent::Async

  attr_reader :update_type, :extra

  def initialize(update_type, extra = nil, disposable: false, &action)
    super()

    @action = action
    @update_type = update_type
    @extra = extra
    @disposable = disposable
  end

  def run(update)
    action.call(update)
  end

  def match?(update, extra = nil)
    update.is_a?(update_type) && (self.extra.nil? || self.extra == extra)
  end

  def disposable?
    disposable
  end

  def to_s
    "TD::UpdateHandler (#{update_type}#{": #{extra}" if extra})#{' disposable' if disposable?}"
  end

  alias inspect to_s

  private

  attr_reader :action, :disposable
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tdlib-ruby-2.2.0 lib/tdlib/update_handler.rb
tdlib-ruby-2.1.0 lib/tdlib/update_handler.rb
tdlib-ruby-2.0.0 lib/tdlib/update_handler.rb