Class: OsCtld::ContinuousExecutor::Command
- Inherits:
-
Object
- Object
- OsCtld::ContinuousExecutor::Command
- Defined in:
- lib/osctld/continuous_executor.rb
Overview
Queueable command
Instance Attribute Summary collapse
- #callable ⇒ Method, Proc
- #id ⇒ any
-
#order ⇒ Integer
Internal queue order.
- #priority ⇒ Integer
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #done(retval) ⇒ Object protected
- #exec ⇒ Object protected
-
#initialize(id: nil, payload: nil, priority: 10, &block) ⇒ Command
constructor
A new instance of Command.
- #return_queue ⇒ Object protected
Constructor Details
#initialize(id: nil, payload: nil, priority: 10, &block) ⇒ Command
Returns a new instance of Command.
28 29 30 31 32 33 |
# File 'lib/osctld/continuous_executor.rb', line 28 def initialize(id: nil, payload: nil, priority: 10, &block) @id = id @priority = priority @callable = block if block @order = 1000 end |
Instance Attribute Details
#callable ⇒ Method, Proc
20 21 22 |
# File 'lib/osctld/continuous_executor.rb', line 20 def callable @callable end |
#id ⇒ any
14 15 16 |
# File 'lib/osctld/continuous_executor.rb', line 14 def id @id end |
#order ⇒ Integer
Returns internal queue order.
23 24 25 |
# File 'lib/osctld/continuous_executor.rb', line 23 def order @order end |
#priority ⇒ Integer
17 18 19 |
# File 'lib/osctld/continuous_executor.rb', line 17 def priority @priority end |
Instance Method Details
#<=>(other) ⇒ Object
35 36 37 |
# File 'lib/osctld/continuous_executor.rb', line 35 def <=>(other) [priority, order] <=> [other.priority, other.order] end |
#done(retval) ⇒ Object (protected)
51 52 53 |
# File 'lib/osctld/continuous_executor.rb', line 51 def done(retval) @return_queue << retval if @return_queue end |
#exec ⇒ Object (protected)
47 48 49 |
# File 'lib/osctld/continuous_executor.rb', line 47 def exec callable.call(self) end |
#return_queue ⇒ Object (protected)
43 44 45 |
# File 'lib/osctld/continuous_executor.rb', line 43 def return_queue @return_queue ||= OsCtl::Lib::Queue.new end |