Class: CleverReach::ResponseDecorator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/clever_reach/response_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResponseDecorator

Returns a new instance of ResponseDecorator.



4
5
6
7
# File 'lib/clever_reach/response_decorator.rb', line 4

def initialize(response)
  super
  @response = response
end

Instance Method Details

#status_codeObject



14
15
16
# File 'lib/clever_reach/response_decorator.rb', line 14

def status_code
  answer_hash[:statuscode].to_i
end

#to_hashObject



18
19
20
21
# File 'lib/clever_reach/response_decorator.rb', line 18

def to_hash
  data = answer_hash[:data]
  clean! data.dup
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/clever_reach/response_decorator.rb', line 9

def valid?
  # Let's be flexible when checking for the status.
  answer_hash[:status] =~ /success/i
end