summaryrefslogtreecommitdiffstats
path: root/state.rb
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-10-08 16:57:00 -0400
committerCasey Dahlin <cdahlin@redhat.com>2008-10-08 16:57:00 -0400
commitf1b64ee8e011494c3d63af9f7c8fa6fb7413e0fb (patch)
treeeb6d5303c25e58d572016edd0e3fc326c4384236 /state.rb
parentbc86c2adc3ac8dbed5667a34398faef10285ac49 (diff)
downloadupstate-f1b64ee8e011494c3d63af9f7c8fa6fb7413e0fb.tar.gz
upstate-f1b64ee8e011494c3d63af9f7c8fa6fb7413e0fb.tar.xz
upstate-f1b64ee8e011494c3d63af9f7c8fa6fb7413e0fb.zip
State#hold and State#release now take a params argument
You may now hold with parameters.
Diffstat (limited to 'state.rb')
-rw-r--r--state.rb20
1 files 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
# <tt>:user</tt> or <tt>:system</tt> 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