Class: Plivo::Resources::LookupResponse
- Inherits:
-
LookupBaseResource
- Object
- LookupBaseResource
- Plivo::Resources::LookupResponse
- Defined in:
- lib/plivo/resources/lookup.rb
Overview
Not subclassing from Base::Resource because it cannot set nested attributes. Named the class ‘LookupResponse’ because the name ‘Number’ is already taken.
Instance Method Summary collapse
-
#initialize(client, options = nil) ⇒ LookupResponse
constructor
A new instance of LookupResponse.
- #parse_and_set(resp) ⇒ Object
Methods inherited from LookupBaseResource
Constructor Details
#initialize(client, options = nil) ⇒ LookupResponse
Returns a new instance of LookupResponse.
34 35 36 37 38 |
# File 'lib/plivo/resources/lookup.rb', line 34 def initialize(client, = nil) # there is no use for client here valid_param?(:options, , Hash, false) parse_and_set([:resource_json]) if .key?(:resource_json) end |
Instance Method Details
#parse_and_set(resp) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/plivo/resources/lookup.rb', line 40 def parse_and_set(resp) return unless resp valid_param?(:resp, resp, Hash, true) resp.each do |k, v| case k when "country" instance_variable_set("@#{k}", Country.new(v)) when "format" instance_variable_set("@#{k}", NumberFormat.new(v)) when "carrier" instance_variable_set("@#{k}", Carrier.new(v)) else instance_variable_set("@#{k}", v) end self.class.send(:attr_reader, k) end end |