Sha256: 7f341a8b6aa5d3d7ef1cfc66559a3c20a662ce012b8fa61a32163e224a0ca118

Contents?: true

Size: 798 Bytes

Versions: 8

Compression:

Stored size: 798 Bytes

Contents

require 'geocoder/results/base'

module Geocoder
  module Result
    class Test < Base

      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

      %w[latitude longitude neighborhood city state state_code sub_state
      sub_state_code province province_code postal_code country
      country_code address street_address street_number route geometry].each do |attr|
        add_result_attribute(attr)
      end

      def initialize(data)
        data.keys.each do |attr|
          Test.add_result_attribute(attr)
        end

        super
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
bw-geocoder-1.2.6 lib/geocoder/results/test.rb
bw-geocoder-1.2.5 lib/geocoder/results/test.rb
geocoder-1.2.5 lib/geocoder/results/test.rb
geocoder-1.2.4 lib/geocoder/results/test.rb
geocoder-1.2.3 lib/geocoder/results/test.rb
geocoder-1.2.2 lib/geocoder/results/test.rb
geocoder-1.2.1 lib/geocoder/results/test.rb
geocoder-1.2.0 lib/geocoder/results/test.rb