Sha256: b890102ca391533e661f6551cac9449a0c795949b341c5bfe62fb80523882643

Contents?: true

Size: 567 Bytes

Versions: 4

Compression:

Stored size: 567 Bytes

Contents

class A

  def test
    puts 'test'
    raise
  end

end

##############################

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'aspector'

class RetryAspect < Aspector::Base

  target do
    def retry_this proxy, &block
      proxy.call &block
    rescue => e
      @retry_count ||= 3
      @retry_count -= 1

      @retry_count = nil or raise if @retry_count == 0

      retry
    end
  end

  around options[:method], :retry_this

end

##############################

RetryAspect.apply(A, :method => :test)

a = A.new
a.test

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aspector-0.10.1 examples/retry_aspect.rb
aspector-0.10.0 examples/retry_aspect.rb
aspector-0.9.1 examples/retry_aspect.rb
aspector-0.9.0 examples/retry_aspect.rb