Sha256: 82c760647c179f32aaa8262e351e24a5e9b5c58c7aa5187972b80c1d9f69b178

Contents?: true

Size: 938 Bytes

Versions: 5

Compression:

Stored size: 938 Bytes

Contents

module Auger

  class Request 
    attr_accessor :tests, :before_tests_proc, :arg

    def self.load(arg, &block)
      request = new(arg)
      request.instance_eval(&block)
      request
    end

    def initialize(arg)
      @arg = arg
      @tests = []
    end

    def test(name, &block)
      @tests << Test.new(name, block)
    end

    ## called within test block to return a Result object
    def Result(*args)
      Auger::Result.new(*args)
    end

    ## callback to be run after request, but before tests
    def before_tests(&block)
      @before_tests_proc = block
    end

    ## call plugin run() and return plugin-specfic response object or exception
    def do_run(conn)
      return conn if conn.is_a? Exception
      begin
        response = self.run(conn)
        response = self.before_tests_proc.call(response) if self.before_tests_proc
        response
      rescue => e
        e
      end
    end

  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
auger-1.3.4 lib/auger/request.rb
auger-1.3.3 lib/auger/request.rb
auger-1.3.2 lib/auger/request.rb
auger-1.3.1 lib/auger/request.rb
auger-1.3.0 lib/auger/request.rb