Module: Telegram::Bot::Async::ClassMethods
- Defined in:
- lib/telegram/bot/async.rb
Instance Method Summary collapse
- #default_async_job ⇒ Object
-
#default_async_job=(val) ⇒ Object
This is used in specs.
-
#prepare_async_args(*args) ⇒ Object
Prepares argments for async job.
-
#prepare_async_val(val) ⇒ Object
Returns default_async_job if ‘true` is given, treats String as a constant name, or bypasses any other values.
Instance Method Details
#default_async_job ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/telegram/bot/async.rb', line 56 def default_async_job @default_async_job ||= begin begin ApplicationJob rescue NameError raise 'Define ApplicationJob class or setup #async= with custom job class' end klass = Class.new(ApplicationJob) { include Job } klass.client_class = self const_set(:AsyncJob, klass) end end |
#default_async_job=(val) ⇒ Object
This is used in specs.
70 71 72 73 |
# File 'lib/telegram/bot/async.rb', line 70 def default_async_job=(val) @default_async_job = val remove_const(:AsyncJob) if const_defined?(:AsyncJob, false) end |
#prepare_async_args(*args) ⇒ Object
Prepares argments for async job. ActiveJob doesn’t support Symbol in argumens. Also we can encode json bodies only once here, so it would not be unnecessarily serialized-deserialized.
This is stub method, which returns input. Every client class must prepare args itself.
81 82 83 |
# File 'lib/telegram/bot/async.rb', line 81 def prepare_async_args(*args) args end |
#prepare_async_val(val) ⇒ Object
Returns default_async_job if ‘true` is given, treats String as a constant name, or bypasses any other values.
87 88 89 90 91 92 93 |
# File 'lib/telegram/bot/async.rb', line 87 def prepare_async_val(val) case val when true then default_async_job when String then Object.const_get(val) else val end end |