Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleaned up the code a bit. also as a result doesn't use closures (I t…

…hink that

technically makes it use less memory, in theory)
  • Loading branch information...
commit 9e97a2c060bb13c1737a5b978e42bf9eac84790c 1 parent c269557
Archit Baweja authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/restarts.rb
11 lib/restarts.rb
View
@@ -18,12 +18,13 @@ def raise_with_restarts(condition)
restart = callcc do |cc|
# Have the continuation object accessible via the #restart method.
# FIXME: check for pre defined methods by the name "restart".
- (class <<condition; self; end).class_eval do
- define_method(:restart) do |*id|
- if id.empty?
- return cc
+ condition.instance_variable_set(:@cc, cc)
+ condition.instance_eval do
+ def restart(id=nil)
+ if id.nil?
+ return @cc
else
- return cc.call(id[0])
+ return @cc.call(id[0])
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.