Sha256: d01268da7ac868a34f4df5c3fd001ffa161409770b6ad450057a0a523b501535

Contents?: true

Size: 754 Bytes

Versions: 10

Compression:

Stored size: 754 Bytes

Contents

module CronoTrigger
  class ExecutionTracker
    def initialize(schedulable)
      @schedulable = schedulable
    end

    def self.track(schedulable, &pr)
      new(schedulable).track(&pr)
    end

    def track(&pr)
      if @schedulable.track_execution
        begin
          execution = @schedulable.crono_trigger_executions.create_with_timestamp!
          result = pr.call
          case result
          when :ok
            execution.complete!
          when :retry
            execution.retrying!
          when :abort
            execution.aborted!
          else
            execution.complete!
          end
        rescue => e
          execution.error!(e)
          raise
        end
      else
        pr.call
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
crono_trigger-0.8.3 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.8.1 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.8.0 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.7.1 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.7.0 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.6.4 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.6.3 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.6.2 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.6.1 lib/crono_trigger/execution_tracker.rb
crono_trigger-0.6.0 lib/crono_trigger/execution_tracker.rb