class DAF::Command
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
Public Class Methods
new(datasource)
click to toggle source
Create a new command object from a data source @param datasource [CommandDataSource] The data source to use to initialize command object
# File lib/daf/command.rb, line 15 def initialize(datasource) @datasource = datasource end
Public Instance Methods
cancel()
click to toggle source
# File lib/daf/command.rb, line 33 def cancel @thread.kill end
execute()
click to toggle source
Begins executing the command by starting the monitor specified in the data source - will return immediately
# 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.action_options) end end end end end