Class: Pina::RestAdapter::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/pina/rest_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code, body) ⇒ Response

Returns a new instance of Response.



120
121
122
123
# File 'lib/pina/rest_adapter.rb', line 120

def initialize(status_code, body)
  @status_code = status_code
  @body        = body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



118
119
120
# File 'lib/pina/rest_adapter.rb', line 118

def body
  @body
end

#status_codeObject

Returns the value of attribute status_code.



118
119
120
# File 'lib/pina/rest_adapter.rb', line 118

def status_code
  @status_code
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/pina/rest_adapter.rb', line 125

def ok?
  status_code == 200 || status_code == 201
end

#to_hashObject



129
130
131
# File 'lib/pina/rest_adapter.rb', line 129

def to_hash
  ActiveSupport::JSON.decode(body)
end