Class: Exotel::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/exotel-api-client/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
# File 'lib/exotel-api-client/response.rb', line 5

def initialize(hash)
  hash.each do |key,value|
    Response.new value if value.class == Hash
    self.instance_variable_set("@#{key}", value)
    self.class.send(:define_method, key, proc{self.instance_variable_get("@#{key}")})
  end
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'lib/exotel-api-client/response.rb', line 3

def errors
  @errors
end

Class Method Details

.construct(response) ⇒ Object



13
14
15
# File 'lib/exotel-api-client/response.rb', line 13

def self.construct(response)
  return response.class == Array ? response.collect { |item| Response.new(item) }  : Response.new(response)
end