Class: SubdivisionResponder::RackApp
- Inherits:
-
Object
- Object
- SubdivisionResponder::RackApp
- Defined in:
- lib/subdivision_responder/rack_app.rb
Constant Summary collapse
- SUBDIVISIONS =
CountryData.subdivisions_by_country_code
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/subdivision_responder/rack_app.rb', line 5 def call(env) request = Rack::Request.new(env) country_code = request.params['country_code'].to_s.upcase data = country_code.empty? ? SUBDIVISIONS : SUBDIVISIONS.select {|k| k == country_code } json = data.to_json [200, {"Content-Type" => "application/json"}, [json]] end |