Class: Volt::Task
- Includes:
- CollectionHelpers
- Defined in:
- lib/volt/tasks/task.rb
Direct Known Subclasses
Class Method Summary collapse
- .inherited(subclass) ⇒ Object
- .known_handlers ⇒ Object
-
.method_missing(name, *args, &block) ⇒ Object
On the backend, we proxy all class methods like we would on the front-end.
Instance Method Summary collapse
-
#initialize(volt_app, channel = nil, dispatcher = nil) ⇒ Task
constructor
A new instance of Task.
-
#timeout(value) ⇒ Object
Set the timeout for method calls on this task.
Methods included from CollectionHelpers
Constructor Details
#initialize(volt_app, channel = nil, dispatcher = nil) ⇒ Task
Returns a new instance of Task.
23 24 25 26 27 28 |
# File 'lib/volt/tasks/task.rb', line 23 def initialize(volt_app, channel = nil, dispatcher = nil) @volt_app = volt_app @page = volt_app.page @channel = channel @dispatcher = dispatcher end |
Class Method Details
.inherited(subclass) ⇒ Object
30 31 32 33 |
# File 'lib/volt/tasks/task.rb', line 30 def self.inherited(subclass) @subclasses ||= [] @subclasses << subclass end |
.known_handlers ⇒ Object
35 36 37 |
# File 'lib/volt/tasks/task.rb', line 35 def self.known_handlers @subclasses ||= [] end |
.method_missing(name, *args, &block) ⇒ Object
On the backend, we proxy all class methods like we would on the front-end. This returns a promise, even if the original code did not.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/volt/tasks/task.rb', line 8 def self.method_missing(name, *args, &block) # Meta data is passed from the browser to the server so the server can know # things like who's logged in. = {} user_id = $page.._user_id ['user_id'] = user_id unless user_id.nil? $page.tasks.call(self.name, name, , *args, &block) end |
Instance Method Details
#timeout(value) ⇒ Object
Set the timeout for method calls on this task. (The default is Volt.config.worker_timeout)
41 42 43 |
# File 'lib/volt/tasks/task.rb', line 41 def timeout(value) self.__timeout = value end |