Sha256: e3285727cd2cf9224ab10c777ef9936e4833bc1a4ba05316c78310b178b7de26

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

module OAuthActiveResource
  
  # just simulates the request and sign! methods of a oauth access token
  class FakeOAuthAccessToken < OAuth::Consumer
    
    attr_accessor :token, :secret
    def initialize()
      @key    = nil
      token = 'Anonymous'
      secret = 'Anonymous'
      
      # ensure that keys are symbols
      @options = @@default_options    
    end
    
    def request(http_method, path, token = nil, request_options = {}, *arguments)
      if path !~ /^\//
        @http = create_http(path)
        _uri = URI.parse(path)
        path = "#{_uri.path}#{_uri.query ? "?#{_uri.query}" : ""}"

      end

      rsp = http.request(create_http_request(http_method, path, token, request_options, *arguments))

      rsp
    end
    
    def get(path, headers = {})
      request(:get, path, headers)
    end
 
    def head(path, headers = {})
      request(:head, path, headers)
    end
 
    def post(path, body = '', headers = {})
      request(:post, path, body, headers)
    end

    def put(path, body = '', headers = {})
      request(:put, path, body, headers)
    end

    def delete(path, headers = {})
      request(:delete, path, headers)
    end
    
    def sign!(*args)
      # do nothing
    end
    
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
jwagener-oauth-active-resource-0.1.5 lib/oauth_active_resource/fake_oauth_access_token.rb
jwagener-oauth-active-resource-0.1.6 lib/oauth_active_resource/fake_oauth_access_token.rb
jwagener-oauth-active-resource-0.1.7 lib/oauth_active_resource/fake_oauth_access_token.rb
jwagener-oauth-active-resource-0.1.8 lib/oauth_active_resource/fake_oauth_access_token.rb
jwagener-oauth-active-resource-0.4.0 lib/oauth_active_resource/fake_oauth_access_token.rb
jwagener-oauth-active-resource-0.4.1 lib/oauth_active_resource/fake_oauth_access_token.rb
oauth-active-resource-0.4.4 lib/oauth_active_resource/fake_oauth_access_token.rb
oauth-active-resource-0.4.2 lib/oauth_active_resource/fake_oauth_access_token.rb