diff options
author | Casey Dahlin <cdahlin@redhat.com> | 2008-10-07 12:50:57 -0400 |
---|---|---|
committer | Casey Dahlin <cdahlin@redhat.com> | 2008-10-07 12:50:57 -0400 |
commit | 8e15964e7bd73a6228652ef341d34f599b3c5345 (patch) | |
tree | 1b2eec3357c0dfe53741557d8fb2f0b2c0a10132 /state.rb | |
parent | b47cbd1a5fbf6a3e6379b0d5720f8b93ff5bc2cc (diff) | |
download | upstate-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.rb | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 |