Class: Rack::LocaleMemorable::Response

Inherits:
Response
  • Object
show all
Defined in:
lib/rack/locale_memorable/response.rb

Instance Method Summary collapse

Instance Method Details

#finishObject



17
18
19
20
# File 'lib/rack/locale_memorable/response.rb', line 17

def finish
  headers['Content-Language'] ||= I18n.locale.to_s
  super
end

#remember_locale(explicit_locale, key:, lifetime: 1.year, domain: nil, path: '/', http_only: true, secure: true) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/rack/locale_memorable/response.rb', line 6

def remember_locale(explicit_locale, key:, lifetime: 1.year, domain: nil, path: '/', http_only: true, secure: true)
  set_cookie key, {
    value:     explicit_locale,
    expires:   lifetime.from_now,
    domain:    domain,
    path:      path,
    http_only: http_only,
    secure:    secure
  }.compact
end