lib/promise.rb in promise-0.1.0 vs lib/promise.rb in promise-0.1.1

- old
+ new

@@ -1,6 +1,5 @@ - ## # A delayed-execution promise. Promises are only executed once. # @example # x = promise { factorial 20 } # y = promise { fibonacci 10**6 } @@ -10,22 +9,22 @@ # @example # y = 5 # x = promise { y = y + 5 } # x + 5 # => 15 # x + 5 # => 15 -class Promise +class Promise < defined?(BasicObject) ? BasicObject : Object - instance_methods.each { |m| undef_method m unless m =~ /__/ } + instance_methods.each { |m| undef_method m unless m =~ /__|object_id/ } unless defined?(BasicObject) # Returns a new promise # @param [Proc] block # @return [Promise] def initialize(block) if block.arity > 0 raise ArgumentError, "Cannot store a promise that requires an argument" end @block = block - @mutex = Mutex.new + @mutex = ::Mutex.new end # Force the evaluation of this promise immediately # @return [Any] def force