Class: Alchemrest::Response::Pipeline::WasSuccessful

Inherits:
Transform
  • Object
show all
Defined in:
lib/alchemrest/response/pipeline/was_successful.rb

Overview

A transform that checks to see if a response was successful, as defined by ‘response.success?`. If the response is successful, it just returns itself. If not it calls `response.error`. Can be used as the first step in any pipeline’s where you want to short circuit execution if the response has an http error code.

Instance Method Summary collapse

Methods inherited from Transform

#failure, #final

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/alchemrest/response/pipeline/was_successful.rb', line 15

def ==(other)
  instance_of?(other.class)
end

#call(response) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/alchemrest/response/pipeline/was_successful.rb', line 19

def call(response)
  if response.success?
    success(response)
  else
    failure(response.error)
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/alchemrest/response/pipeline/was_successful.rb', line 11

def eql?(other)
  instance_of?(other.class)
end