class PostcodeAnywhere::Request

Attributes

body[RW]
client[RW]
options[RW]
path[RW]
request_method[RW]
verb[RW]

Public Class Methods

new(client, request_method, path, body_hash = {}, options = {}) click to toggle source
# File lib/postcode_anywhere/request.rb, line 6
def initialize(client, request_method, path, body_hash = {}, options = {})
  @client = client
  @request_method = request_method.to_sym
  @path = path
  @body_hash = body_hash
  @options = options
end

Public Instance Methods

perform() click to toggle source
# File lib/postcode_anywhere/request.rb, line 14
def perform
  @client.send(@request_method, @path, @body_hash, @options).body
end
perform_with_object(klass) click to toggle source
# File lib/postcode_anywhere/request.rb, line 18
def perform_with_object(klass)
  result = perform
  if result.class == Array
    klass.new(result.first)
  else
    klass.new(result)
  end
end
perform_with_objects(klass) click to toggle source
# File lib/postcode_anywhere/request.rb, line 27
def perform_with_objects(klass)
  perform.map do |element|
    klass.new(element)
  end
end