Class: Bloodbath::Adapters::Rest

Inherits:
Object
  • Object
show all
Includes:
Utils::Threading
Defined in:
lib/bloodbath/event.rb

Constant Summary

Constants included from Utils::Threading

Utils::Threading::MAX_ACTIVE_THREADS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Threading

join_all_threads, #threading

Constructor Details

#initialize(method:, endpoint:, body: nil, options:, config: Bloodbath.config) ⇒ Rest

Returns a new instance of Rest.



17
18
19
20
21
22
23
# File 'lib/bloodbath/event.rb', line 17

def initialize(method:, endpoint:, body: nil, options:, config: Bloodbath.config)
  @method = method
  @endpoint = endpoint
  @body = body
  @options = options
  @config = config
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



15
16
17
# File 'lib/bloodbath/event.rb', line 15

def body
  @body
end

#configObject (readonly)

Returns the value of attribute config.



15
16
17
# File 'lib/bloodbath/event.rb', line 15

def config
  @config
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



15
16
17
# File 'lib/bloodbath/event.rb', line 15

def endpoint
  @endpoint
end

#methodObject (readonly)

Returns the value of attribute method.



15
16
17
# File 'lib/bloodbath/event.rb', line 15

def method
  @method
end

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/bloodbath/event.rb', line 15

def options
  @options
end

Instance Method Details

#performObject



25
26
27
28
29
30
31
32
33
# File 'lib/bloodbath/event.rb', line 25

def perform
  check_api_key

  if options[:wait_for_response]
    synchronous_call_with_response
  else
    asynchronously { synchronous_call_with_response }
  end
end