Sha256: f99d67a8f1a7180d1bae40d08faf5fb7d2965bd2e7f95c78f3ac5a174949327a

Contents?: true

Size: 445 Bytes

Versions: 5

Compression:

Stored size: 445 Bytes

Contents

module Massive
  module Cancelling
    extend ActiveSupport::Concern

    # Override this to provide logic for whether it should be cancelled or not
    def cancelled?
    end

    def cancelling(&block)
      raise Massive::Cancelled.new(cancelled_exception_message) if cancelled?
      block.call
    end

    private

    def cancelled_exception_message
      "Cancelled #{self.class.name} - #{self.id if respond_to?(:id)}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
massive-0.4.0 lib/massive/cancelling.rb
massive-0.3.0 lib/massive/cancelling.rb
massive-0.2.0 lib/massive/cancelling.rb
massive-0.1.1 lib/massive/cancelling.rb
massive-0.1.0 lib/massive/cancelling.rb