lib/dirty_pipeline/status.rb in dirty_pipeline-0.3.0 vs lib/dirty_pipeline/status.rb in dirty_pipeline-0.4.0
- old
+ new
@@ -14,58 +14,42 @@
yield
self
end
def success?
- succeeded
+ !!succeeded
end
def when_success(callback = nil)
return self unless success?
- if block_given?
- yield(self)
- else
- callback.call(self)
- end
+ block_given? ? yield(self) : callback.(self)
self
end
def when_failed(callback = nil)
return self unless storage.failed?
- if block_given?
- yield(self)
- else
- callback.call(self)
- end
+ block_given? ? yield(self) : callback.(self)
self
end
def errored?
return if succeeded.nil?
ready? && !succeeded
end
def when_error(callback = nil)
return self unless errored?
- if block_given?
- yield(self)
- else
- callback.call(self)
- end
+ block_given? ? yield(self) : callback.(self)
self
end
def ready?
storage.pipeline_status.nil?
end
def when_processing(callback = nil)
return self unless storage.processing?
- if block_given?
- yield(self)
- else
- callback.call(self)
- end
+ block_given? ? yield(self) : callback.(self)
self
end
end
end