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.
29 30 31 32 33 34 |
# File 'lib/osctld/continuous_executor.rb', line 29 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
21 22 23 |
# File 'lib/osctld/continuous_executor.rb', line 21 def callable @callable end |
#id ⇒ any
15 16 17 |
# File 'lib/osctld/continuous_executor.rb', line 15 def id @id end |
#order ⇒ Integer
Returns internal queue order.
24 25 26 |
# File 'lib/osctld/continuous_executor.rb', line 24 def order @order end |
#priority ⇒ Integer
18 19 20 |
# File 'lib/osctld/continuous_executor.rb', line 18 def priority @priority end |
Instance Method Details
#<=>(other) ⇒ Object
36 37 38 |
# File 'lib/osctld/continuous_executor.rb', line 36 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 |