Class: Rack::GeoIPCountry::Mapping

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/geoipcountry.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Mapping

Returns a new instance of Mapping.



48
49
50
51
# File 'lib/rack/geoipcountry.rb', line 48

def initialize(app, options = {})
  @app, @prefix = app, /^#{options.delete(:prefix)}/
  @geoip_country = GeoIPCountry.new(app, options)
end

Instance Method Details

#call(env) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/rack/geoipcountry.rb', line 53

def call(env)
  if env['PATH_INFO'] =~ @prefix
    @geoip_country.call(env)
  else
    @app.call(env)
  end
end