lib/volt/tasks/task.rb in volt-0.9.5.pre9 vs lib/volt/tasks/task.rb in volt-0.9.5.pre11
- old
+ new
@@ -1,6 +1,7 @@
require 'volt/controllers/collection_helpers'
+require 'volt/controllers/login_as_helper'
module Volt
class Task
if RUBY_PLATFORM == 'opal'
# On the front-end we setup a proxy class to the backend that returns
@@ -15,10 +16,11 @@
Volt.current_app.tasks.call(self.name, name, meta_data, *args, &block)
end
else
include CollectionHelpers
+ include LoginAsHelper
class_attribute :__timeout
def initialize(volt_app, channel = nil, dispatcher = nil)
@volt_app = volt_app
@@ -37,9 +39,20 @@
# Set the timeout for method calls on this task. (The default is
# Volt.config.worker_timeout)
def timeout(value)
self.__timeout = value
+ end
+
+ def cookies
+ @cookies ||= Model.new
+ end
+
+ # Get the cookies that got set
+ def fetch_cookies
+ if @cookies
+ @cookies.to_h.reject {|k,v| k == :id }
+ end
end
# 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.