Class: Geocoder::Result::Test
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Test
constructor
A new instance of Test.
Methods inherited from Base
#address, #coordinates, #country, #country_code, #latitude, #longitude, #province, #province_code, #state, #state_code
Constructor Details
#initialize(data) ⇒ Test
Returns a new instance of Test.
24 25 26 27 28 29 30 |
# File 'lib/geocoder/results/test.rb', line 24 def initialize(data) data.each_key do |attr| Test.add_result_attribute(attr) end super end |
Class Method Details
.add_result_attribute(attr) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/geocoder/results/test.rb', line 7 def self.add_result_attribute(attr) begin remove_method(attr) if method_defined?(attr) rescue NameError # method defined on superclass end define_method(attr) do @data[attr.to_s] || @data[attr.to_sym] end end |