Module: Geos::GoogleMaps

Defined in:
lib/geos/google_maps.rb,
lib/geos/google_maps/api_3.rb,
lib/geos/google_maps/api_common.rb,
lib/geos/google_maps/polyline_encoder.rb

Defined Under Namespace

Modules: Api2, Api3, Api3Constants, ApiCommon, PolylineEncoder

Class Method Summary collapse

Class Method Details

.use_api(version) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/geos/google_maps.rb', line 5

def use_api(version)
  version_const = Geos::GoogleMaps.const_get("Api#{version}")
  version_const.constants.each do |c|
    mod = version_const.const_get(c)
    klass = Geos.const_get(c)
    regex = %r{_api#{version}$}

    if !klass.include?(mod)
      klass.send(:include, mod)
    end

    mod.instance_methods.each do |method|
      klass.send(:alias_method, method.to_s.sub(regex, ''), method)
    end
  end
end