Class: RubyMailman::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_mailman/response.rb

Direct Known Subclasses

FailResponse, RetryResponse, SuccessResponse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Response

Returns a new instance of Response.



31
32
33
# File 'lib/ruby_mailman/response.rb', line 31

def initialize(body)
  self.body = body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/ruby_mailman/response.rb', line 3

def body
  @body
end

Class Method Details

.build(raw_response) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ruby_mailman/response.rb', line 4

def self.build(raw_response)
  #Work with both a string "200" and an array ["200"]
  raw_response = Array(raw_response).join
  case raw_response
  when "200"
    SuccessResponse.new(raw_response)
  when "409"
    RetryResponse.new(raw_response)
  when "500"
    FailResponse.new(raw_response)
  else
    self.new(raw_response)
  end
end

Instance Method Details

#fail?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ruby_mailman/response.rb', line 27

def fail?
  false
end

#retry?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ruby_mailman/response.rb', line 23

def retry?
  false
end

#success?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ruby_mailman/response.rb', line 19

def success?
  false
end