summaryrefslogtreecommitdiffstats
path: root/state.rb
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-10-07 12:50:57 -0400
committerCasey Dahlin <cdahlin@redhat.com>2008-10-07 12:50:57 -0400
commit8e15964e7bd73a6228652ef341d34f599b3c5345 (patch)
tree1b2eec3357c0dfe53741557d8fb2f0b2c0a10132 /state.rb
parentb47cbd1a5fbf6a3e6379b0d5720f8b93ff5bc2cc (diff)
downloadupstate-8e15964e7bd73a6228652ef341d34f599b3c5345.tar.gz
upstate-8e15964e7bd73a6228652ef341d34f599b3c5345.tar.xz
upstate-8e15964e7bd73a6228652ef341d34f599b3c5345.zip
Add State::release to compliment State::hold
State::release can be called to release all states of a type. Also State::hold and State::release both now return a list of states they attempted to act on.
Diffstat (limited to 'state.rb')
-rw-r--r--state.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/state.rb b/state.rb
index 2f80ab3..eb2498a 100644
--- a/state.rb
+++ b/state.rb
@@ -243,13 +243,19 @@ class State
# Hold all states of a class
def State.hold(type)
- @@states.select{ |x| x.is_a? self }.each{ |x| x.hold(type) }
+ @@states.select{ |x| x.is_a? self }.map{ |x| x.hold(type) }
+ end
+
+ # Release all states of a class
+ def State.release(type)
+ @@states.select{ |x| x.is_a? self }.map{ |x| x.release(type) }
end
private
# Set this state to true
def rise
return if @active
+ trace "Raising #{self}"
@deps.each{ |x| x.hold(self) }
self.class.rising_edge.call(params)
@active = true