Class: Rack::UserLocale
- Inherits:
-
Object
- Object
- Rack::UserLocale
- Defined in:
- lib/user_locale.rb,
lib/rack/user-locale/version.rb
Constant Summary collapse
- VERSION =
::File.read(version_file).split("\n").first
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ UserLocale
constructor
A new instance of UserLocale.
Constructor Details
#initialize(app, options = {}) ⇒ UserLocale
Returns a new instance of UserLocale.
9 10 11 12 13 14 15 |
# File 'lib/user_locale.rb', line 9 def initialize(app, = {}) @app = app @options = { accepted_locales: [], cookie_name: "user-locale" }.merge() end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/user_locale.rb', line 7 def app @app end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/user_locale.rb', line 7 def body @body end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
7 8 9 |
# File 'lib/user_locale.rb', line 7 def env @env end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/user_locale.rb', line 7 def headers @headers end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/user_locale.rb', line 7 def @options end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/user_locale.rb', line 7 def status @status end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/user_locale.rb', line 17 def call(env) @env = env set_i18n app.call(env) && return unless request.get? @status, @headers, @body = app.call(env) response.finish end |