Sha256: 4c3e308264ceb7890598ec3201eb2d5e03c44417d9df7763f3561b0cfb574bca
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
module Elevate class ElevateOperation < NSOperation def initWithTarget(target) if init() @target = target @coordinator = IOCoordinator.new @dispatcher = Dispatcher.new setCompletionBlock(lambda do @target = nil @dispatcher.invoke_finished_callback() unless isCancelled() @dispatcher.dispose() end) end self end def cancel @coordinator.cancel() super end def dealloc #puts 'dealloc!' super end def inspect details = [] details << "<canceled>" if @coordinator.cancelled? details << "@target=#{@target.class.name}" "#<#{self.class.name}: #{details.join(" ")}>" end def log(line) puts line unless RUBYMOTION_ENV == "test" end def main log " START: #{inspect}" @coordinator.install() begin unless @coordinator.cancelled? @result = @target.execute end rescue => e @exception = e end @coordinator.uninstall() log "FINISH: #{inspect}" end attr_reader :exception attr_reader :result def on_started=(callback) @dispatcher.on_started = callback end def on_finished=(callback) @dispatcher.on_finished = callback end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elevate-0.3.1 | lib/elevate/operation.rb |
elevate-0.3 | lib/elevate/operation.rb |