Class: ViaCep::Instance
- Inherits:
-
Object
- Object
- ViaCep::Instance
- Defined in:
- lib/via_cep/instance.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#define_attributes(response) ⇒ Object
Default class to define methods based on the response.
Instance Method Details
#define_attributes(response) ⇒ Object
Default class to define methods based on the response
return [ViaCep::Instance]
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/via_cep/instance.rb', line 10 def define_attributes(response) ViaCep::METHODS.each do |method_name, response_key| value = response[response_key.to_s] instance_variable_set("@#{method_name}", value) self.class.define_method(method_name) do instance_variable_get("@#{method_name}") end end end |