class ApiBomb::Fighter

Attributes

base_url[R]
options[R]
paths[R]

Public Class Methods

new(paths: nil, base_url: nil, options: {}) click to toggle source
# File lib/api_bomb/fighter.rb, line 6
def initialize(paths: nil, base_url: nil, options: {})
  @base_url = base_url
  @options = options
  @paths = paths
end

Public Instance Methods

fire() click to toggle source
# File lib/api_bomb/fighter.rb, line 12
def fire
  route = @paths.pick

  url = URI::join(base_url, route.path)
  response = nil
  hold_time = Benchmark.measure do
    response = HTTP.send(
      route.action,
      url,
      ApiBomb::LambdaHash.hasharize(options.merge(route.options))
    )
  end

  return OpenStruct.new(response: response, hold_time: hold_time.real)
end