Class: TD::UpdateHandler
- Inherits:
-
Object
- Object
- TD::UpdateHandler
- Includes:
- Concurrent::Async
- Defined in:
- lib/tdlib/update_handler.rb
Instance Attribute Summary collapse
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
-
#update_type ⇒ Object
readonly
Returns the value of attribute update_type.
Instance Method Summary collapse
- #disposable? ⇒ Boolean
-
#initialize(update_type, extra = nil, disposable: false, &action) ⇒ UpdateHandler
constructor
A new instance of UpdateHandler.
- #match?(update, extra = nil) ⇒ Boolean
- #run(update) ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(update_type, extra = nil, disposable: false, &action) ⇒ UpdateHandler
Returns a new instance of UpdateHandler.
6 7 8 9 10 11 12 13 |
# File 'lib/tdlib/update_handler.rb', line 6 def initialize(update_type, extra = nil, disposable: false, &action) super() @action = action @update_type = update_type @extra = extra @disposable = disposable end |
Instance Attribute Details
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
4 5 6 |
# File 'lib/tdlib/update_handler.rb', line 4 def extra @extra end |
#update_type ⇒ Object (readonly)
Returns the value of attribute update_type.
4 5 6 |
# File 'lib/tdlib/update_handler.rb', line 4 def update_type @update_type end |
Instance Method Details
#disposable? ⇒ Boolean
26 27 28 |
# File 'lib/tdlib/update_handler.rb', line 26 def disposable? disposable end |
#match?(update, extra = nil) ⇒ Boolean
22 23 24 |
# File 'lib/tdlib/update_handler.rb', line 22 def match?(update, extra = nil) update.is_a?(update_type) && (self.extra.nil? || self.extra == extra) end |
#run(update) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/tdlib/update_handler.rb', line 15 def run(update) action.call(update) rescue StandardError => e warn("Uncaught exception in handler #{self}: #{e.}") raise end |
#to_s ⇒ Object Also known as: inspect
30 31 32 |
# File 'lib/tdlib/update_handler.rb', line 30 def to_s "TD::UpdateHandler (#{update_type}#{": #{extra}" if extra})#{' disposable' if disposable?}" end |