Class: Volt::Task
- Includes:
- CollectionHelpers, LoginAsHelper
- 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.
-
.timeout(value) ⇒ Object
Set the timeout for method calls on this task.
Instance Method Summary collapse
- #cookies ⇒ Object
-
#fetch_cookies ⇒ Object
Get the cookies that got set.
-
#initialize(volt_app, channel = nil, dispatcher = nil) ⇒ Task
constructor
A new instance of Task.
Methods included from LoginAsHelper
Methods included from CollectionHelpers
#channel, #flash, #local_store, #page, #params, #store, #tasks, #url, #url_for, #url_with
Constructor Details
#initialize(volt_app, channel = nil, dispatcher = nil) ⇒ Task
Returns a new instance of Task.
25 26 27 28 29 |
# File 'lib/volt/tasks/task.rb', line 25 def initialize(volt_app, channel = nil, dispatcher = nil) @volt_app = volt_app @channel = channel @dispatcher = dispatcher end |
Class Method Details
.inherited(subclass) ⇒ Object
31 32 33 34 |
# File 'lib/volt/tasks/task.rb', line 31 def self.inherited(subclass) @subclasses ||= [] @subclasses << subclass end |
.known_handlers ⇒ Object
36 37 38 |
# File 'lib/volt/tasks/task.rb', line 36 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.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/volt/tasks/task.rb', line 9 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 = Volt.current_app.._user_id ['user_id'] = user_id unless user_id.nil? Volt.current_app.tasks.call(self.name, name, , *args, &block) end |
.timeout(value) ⇒ Object
Set the timeout for method calls on this task. (The default is Volt.config.worker_timeout) Set 0 to disable timeout
43 44 45 |
# File 'lib/volt/tasks/task.rb', line 43 def self.timeout(value) self.__timeout = value end |