Sha256: 15f90a6a041746b893cd5b2137f2326c8633706786fca7f76448a0ddc72e16ac

Contents?: true

Size: 852 Bytes

Versions: 5

Compression:

Stored size: 852 Bytes

Contents

module Autodoc
  class Transaction
    def self.build(context)
      if defined?(Rack::Test::Methods) && context.class.ancestors.include?(Rack::Test::Methods)
        self.new(ActionDispatch::Request.new(context.last_request.env), context.last_response)
      else
        self.new(context.request, context.response)
      end
    end

    attr_accessor :request, :response

    def initialize(*args)
      @request, @response = *args
    end

    def method
      request.method
    end

    def request_body
      request.body.string
    end

    def response_status
      response.status
    end

    def response_header(header)
      response.headers[header]
    end

    def response_body_raw
      response.body
    end

    def controller
      request.params[:controller]
    end

    def action
      request.params[:action]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
autodoc-0.2.2 lib/autodoc/transaction.rb
autodoc-0.2.1 lib/autodoc/transaction.rb
autodoc-0.2.0 lib/autodoc/transaction.rb
autodoc-0.1.9 lib/autodoc/transaction.rb
autodoc-0.1.8 lib/autodoc/transaction.rb