Class: Threadless
- Inherits:
-
Object
- Object
- Threadless
- Defined in:
- lib/threadless.rb
Overview
A single threaded runlater implementation
Defined Under Namespace
Modules: InstanceMethods Classes: Adapter, Executor
Constant Summary collapse
- ENV_KEY =
"rack.threadless.run_later"
Class Method Summary collapse
- .background=(m) ⇒ Object
- .background?(m) ⇒ Boolean
-
.init ⇒ Object
– activate instance methods and middleware, on Rails.
Instance Method Summary collapse
-
#call(env) ⇒ Object
The metal interface: call.
-
#initialize(app) ⇒ Threadless
constructor
The metal interface: initializing.
Constructor Details
#initialize(app) ⇒ Threadless
The metal interface: initializing
71 72 73 |
# File 'lib/threadless.rb', line 71 def initialize(app) @app = app end |
Class Method Details
.background=(m) ⇒ Object
16 17 18 |
# File 'lib/threadless.rb', line 16 def self.background=(m) @background = m end |
.background?(m) ⇒ Boolean
12 13 14 |
# File 'lib/threadless.rb', line 12 def self.background?(m) @background end |
.init ⇒ Object
– activate instance methods and middleware, on Rails
87 88 89 90 91 92 93 |
# File 'lib/threadless.rb', line 87 def self.init ActionController::Base.send(:include, Threadless::InstanceMethods) ActionController::Base.send(:helper, Threadless::InstanceMethods) middleware = ActionController::MiddlewareStack::Middleware.new(self) ActionController::Dispatcher.middleware.push middleware end |
Instance Method Details
#call(env) ⇒ Object
The metal interface: call
77 78 79 80 81 82 83 |
# File 'lib/threadless.rb', line 77 def call(env) status, headers, body = *@app.call(env) body = Executor.new(body, env[ENV_KEY]) if env[ENV_KEY] [ status, headers, body ] end |