module Czar::Command
Attributes
parent[RW]
Public Instance Methods
children()
click to toggle source
# File lib/czar/command.rb, line 21 def children @children ||= [] end
completed?()
click to toggle source
# File lib/czar/command.rb, line 13 def completed? state == :complete end
execute()
click to toggle source
# File lib/czar/command.rb, line 4 def execute self.send self.state if self.respond_to? self.state return self end
result()
click to toggle source
# File lib/czar/command.rb, line 9 def result internal[:result] end
state()
click to toggle source
# File lib/czar/command.rb, line 17 def state @state ||= :start end
Protected Instance Methods
child_task_completed(child_task)
click to toggle source
# File lib/czar/command.rb, line 50 def child_task_completed child_task end
internal()
click to toggle source
# File lib/czar/command.rb, line 42 def internal @internal_state ||= {} end
mark_as(state, params = {})
click to toggle source
# File lib/czar/command.rb, line 36 def mark_as state, params = {} @state = state.to_sym @internal_state = internal.merge(params) notify_parent if @state == :complete end
notify_parent()
click to toggle source
# File lib/czar/command.rb, line 46 def notify_parent parent.child_task_completed self unless parent.nil? end
perform(child_task)
click to toggle source
# File lib/czar/command.rb, line 29 def perform child_task return if child_task.nil? child_task.parent = self children << child_task child_task.execute end