Class: Asynchronic::Environment
- Inherits:
-
Object
- Object
- Asynchronic::Environment
- Defined in:
- lib/asynchronic/environment.rb
Instance Attribute Summary collapse
-
#data_store ⇒ Object
readonly
Returns the value of attribute data_store.
-
#notifier ⇒ Object
readonly
Returns the value of attribute notifier.
-
#queue_engine ⇒ Object
readonly
Returns the value of attribute queue_engine.
Instance Method Summary collapse
- #create_process(type, params = {}) ⇒ Object
- #default_queue ⇒ Object
- #enqueue(msg, queue = nil) ⇒ Object
-
#initialize(queue_engine, data_store, notifier) ⇒ Environment
constructor
A new instance of Environment.
- #load_process(id) ⇒ Object
- #processes ⇒ Object
- #queue(name) ⇒ Object
Constructor Details
#initialize(queue_engine, data_store, notifier) ⇒ Environment
Returns a new instance of Environment.
6 7 8 9 10 |
# File 'lib/asynchronic/environment.rb', line 6 def initialize(queue_engine, data_store, notifier) @queue_engine = queue_engine @data_store = data_store @notifier = notifier end |
Instance Attribute Details
#data_store ⇒ Object (readonly)
Returns the value of attribute data_store.
4 5 6 |
# File 'lib/asynchronic/environment.rb', line 4 def data_store @data_store end |
#notifier ⇒ Object (readonly)
Returns the value of attribute notifier.
4 5 6 |
# File 'lib/asynchronic/environment.rb', line 4 def notifier @notifier end |
#queue_engine ⇒ Object (readonly)
Returns the value of attribute queue_engine.
4 5 6 |
# File 'lib/asynchronic/environment.rb', line 4 def queue_engine @queue_engine end |
Instance Method Details
#create_process(type, params = {}) ⇒ Object
24 25 26 |
# File 'lib/asynchronic/environment.rb', line 24 def create_process(type, params={}) Process.create self, type, params end |
#default_queue ⇒ Object
16 17 18 |
# File 'lib/asynchronic/environment.rb', line 16 def default_queue queue queue_engine.default_queue end |
#enqueue(msg, queue = nil) ⇒ Object
20 21 22 |
# File 'lib/asynchronic/environment.rb', line 20 def enqueue(msg, queue=nil) queue(queue || queue_engine.default_queue).push msg end |
#load_process(id) ⇒ Object
28 29 30 |
# File 'lib/asynchronic/environment.rb', line 28 def load_process(id) Process.new self, id end |
#processes ⇒ Object
32 33 34 |
# File 'lib/asynchronic/environment.rb', line 32 def processes Process.all self end |
#queue(name) ⇒ Object
12 13 14 |
# File 'lib/asynchronic/environment.rb', line 12 def queue(name) queue_engine[name] end |