Class: MekariSso::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/requests/sender.rb

Instance Method Summary collapse

Constructor Details

#initialize(request = []) ⇒ Sender

Returns a new instance of Sender.



8
9
10
# File 'lib/requests/sender.rb', line 8

def initialize(request = [])
  @request = request
end

Instance Method Details

#<<(request) ⇒ Object



12
13
14
# File 'lib/requests/sender.rb', line 12

def <<(request)
  @request << request
end

#>>(other) ⇒ Object



16
17
18
# File 'lib/requests/sender.rb', line 16

def >>(other)
  send(other)
end

#send(request) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/requests/sender.rb', line 20

def send(request)
  return unless request.present?

  request.handle_response(request.send)
rescue RestClient::ExceptionWithResponse => e
  response = e.response.present? ? e.response : e.message
  request.handle_error(response, e)
rescue StandardError => e
  request.handle_error(e.message, e)
rescue RestClient::NotFound => e
  request.handle_error(e.message, e)
end