b0VIM 7.4dTSamuellocalhost~Samuel/Workspace/ruby/rpromise/lib/rpromise/promise.rbutf-8 3210#"! UtpeadKega`uf`_. ~ = ] W V F !   m Z Y @ ) !   { u t h g L  f ] 8 0 /   VPOKend end end handler.resolve.call(output) unleend eeeeeeeeeeeeeeeeeeeeend end handler.reject.call(nil) unless handler.reject.nil? rescue end handler.resolve.call(output) unless handler.resolve.nil? output = callback.call(@value) output = nil unless callback.nil? end callback = handler.on_rejected else callback = handler.on_resolved if resolved? callback = nil end return nil @defered = handler if pending? def handle(handler) end return arg.nil? || arg.is_a?(Proc) || arg.is_a?(Method) def is_valid_block?(arg) protected end end handle(@defered) unless @defered.nil? @value = value @state = State::REJECTED def reject!(value = nil) end reject!(nil) rescue end handle(@defered) unless @defered.nil? @value = value @state = State::RESOLVED end return value.then(method(:resolve!), method(:reject!)) if value.is_a?(::Rpromise::Promise) def resolve!(value = nil) end return @state == State::REJECTED def rejected? end return @state == State::RESOLVED def resolved? end return @state == State::PENDING def pending? end end self.handle(handler) handler = Handler.new(on_resolved, on_rejected, resolve, reject) return ::Rpromise::Promise.new do |resolve, reject, promise| return self if on_resolved.nil? && on_rejected.nil? raise ArgumentError unless is_valid_block?(on_rejected) raise ArgumentError unless is_valid_block?(on_resolved) def then(on_resolved = nil, on_rejected = nil) end reject!(e) rescue Exception => e yield(method(:resolve!), method(:reject!),self) @defered = nil @state = State::PENDING def initialize() attr_reader :state Handler = Struct.new(:on_resolved, :on_rejected, :resolve, :reject) end REJECTED = :rejected RESOLVED = :resolved PENDING = :pending module Stateclass ::Rpromise::Promiserequire 'pry'require 'rpromise'