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



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

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

#remember_locale(explicit_locale, key:, lifetime: 31536000, domain: nil, path: '/', http_only: true, secure: true, same_site: nil) ⇒ Object



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

def remember_locale(explicit_locale, key:, lifetime: 31536000, domain: nil, path: '/', http_only: true, secure: true, same_site: nil)
  set_cookie key, {
    value:     explicit_locale,
    expires:   Time.at(Time.now.to_i + lifetime.to_i),
    domain:    domain,
    path:      path,
    http_only: http_only,
    secure:    secure,
    same_site: same_site
  }.compact
end