class Nimbu::Request::ContentLocale

Constants

CONTENT_LOCALE

Public Class Methods

new(app, *args) click to toggle source
Calls superclass method
# File lib/nimbu-api/request/content_locale.rb, line 21
def initialize(app, *args)
  super app
  @app = app
  @content_locale = args.shift
end

Public Instance Methods

call(env) click to toggle source
# File lib/nimbu-api/request/content_locale.rb, line 12
def call(env)
  if @content_locale
    params =  { CONTENT_LOCALE => @content_locale }.update query_params(env[:url])
    env[:url].query = build_query params
  end

  @app.call env
end
query_params(url) click to toggle source
# File lib/nimbu-api/request/content_locale.rb, line 27
def query_params(url)
  if url.query.nil? or url.query.empty?
    {}
  else
    parse_query url.query
  end
end