From 8e15964e7bd73a6228652ef341d34f599b3c5345 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Tue, 7 Oct 2008 12:50:57 -0400 Subject: 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. --- state.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit