Module: Thaum::Action
- Defined in:
- lib/thaum/action.rb
Overview
Mixin that turns a plain class into a background “action”.
Including this module promotes every public instance method into a class method (see ClassMethods#method_added). Calling that class method schedules the work on the run loop’s background thread pool:
- A fresh instance is built with an argless `new`, so Actions must not
require constructor arguments.
- The method runs fire-and-forget; its return value is discarded.
- Use {#emit} to push results back to the run loop as events.
- Calling a promoted method outside a running Thaum app (no pool) raises
{Thaum::Error}.
Defined Under Namespace
Modules: ClassMethods
Class Attribute Summary collapse
-
.pool ⇒ Object
Returns the value of attribute pool.
-
.queue ⇒ Object
Returns the value of attribute queue.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.pool ⇒ Object
Returns the value of attribute pool.
18 19 20 |
# File 'lib/thaum/action.rb', line 18 def pool @pool end |
.queue ⇒ Object
Returns the value of attribute queue.
18 19 20 |
# File 'lib/thaum/action.rb', line 18 def queue @queue end |
Class Method Details
.included(base) ⇒ Object
21 22 23 |
# File 'lib/thaum/action.rb', line 21 def self.included(base) base.extend(ClassMethods) end |