Class: DAF::Command
- Inherits:
-
Object
- Object
- DAF::Command
- Defined in:
- lib/daf/command.rb
Overview
Represents a pair of Action and Monitor objects when requested, will begin watching the Monitor and when it triggers will invoke the action by default Command continues monitoring forever though subclasses may override this behavior
Instance Method Summary collapse
- #cancel ⇒ Object
-
#execute ⇒ Object
Begins executing the command by starting the monitor specified in the data source - will return immediately.
-
#initialize(datasource) ⇒ Command
constructor
Create a new command object from a data source command object.
Constructor Details
#initialize(datasource) ⇒ Command
Create a new command object from a data source command object
15 16 17 |
# File 'lib/daf/command.rb', line 15 def initialize(datasource) @datasource = datasource end |
Instance Method Details
#cancel ⇒ Object
33 34 35 |
# File 'lib/daf/command.rb', line 33 def cancel @thread.kill end |
#execute ⇒ Object
Begins executing the command by starting the monitor specified in the data source - will return immediately
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/daf/command.rb', line 21 def execute @thread = Thread.new do if Thread.current != Thread.main loop do @datasource.monitor.on_trigger do @datasource.action.activate(@datasource.) end end end end end |