From f1b64ee8e011494c3d63af9f7c8fa6fb7413e0fb Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Wed, 8 Oct 2008 16:57:00 -0400 Subject: State#hold and State#release now take a params argument You may now hold with parameters. --- state.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/state.rb b/state.rb index c8a39b2..5ebedea 100644 --- a/state.rb +++ b/state.rb @@ -116,10 +116,10 @@ class State # type State to establish that said state depends on this one, or one of # :user or :system to establish that the user or system # has an interest in keeping this service running - def hold(hold) + def hold(hold, params = {}) hold = Hold::Dep.new(hold) if hold.is_a? State - hold = Hold::User.new if hold == :user - hold = Hold::System.new if hold == :system + hold = Hold::User.new(params) if hold == :user + hold = Hold::System.new(params) if hold == :system raise TypeError unless hold.is_a? Hold trace "#{self} being held with #{hold}" @holds.add hold @@ -128,10 +128,10 @@ class State end # Release a hold on this state. Arguments are the same as for +hold+. - def release(hold) + def release(hold, params = {}) hold = Hold::Dep.new(hold) if hold.is_a? State - hold = Hold::User.new if hold == :user - hold = Hold::System.new if hold == :system + hold = Hold::User.new(params) if hold == :user + hold = Hold::System.new(params) if hold == :system raise TypeError unless hold.is_a? Hold trace "#{self} being released from #{hold}" @holds.delete hold @@ -263,13 +263,13 @@ class State end # Hold all states of a class - def State.hold(type) - @@states.select{ |x| x.is_a? self }.map{ |x| x.hold(type) } + def State.hold(type, params = {}) + @@states.select{ |x| x.is_a? self }.map{ |x| x.hold(type, params) } end # Release all states of a class - def State.release(type) - @@states.select{ |x| x.is_a? self }.map{ |x| x.release(type) } + def State.release(type, params = {}) + @@states.select{ |x| x.is_a? self }.map{ |x| x.release(type, params) } end private -- cgit