Class: RequestInfo::DetectorApp
- Inherits:
-
Object
- Object
- RequestInfo::DetectorApp
- Defined in:
- lib/request_info/detector_app.rb
Overview
Rack middleware to process all specified detectors and sets results for the current thread
Constant Summary collapse
- DEFAULT_DETECTORS =
TODO: make this list of detectors available for others to add/change
[ RequestInfo::Detectors::IpDetector, RequestInfo::Detectors::BrowserDetector, RequestInfo::Detectors::TimezoneDetector, RequestInfo::Detectors::LocaleDetector, ].freeze
Class Attribute Summary collapse
-
.detectors ⇒ Object
Returns the value of attribute detectors.
Instance Attribute Summary collapse
-
#analyzer ⇒ Object
readonly
Returns the value of attribute analyzer.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ DetectorApp
constructor
A new instance of DetectorApp.
Constructor Details
#initialize(app) ⇒ DetectorApp
Returns a new instance of DetectorApp.
27 28 29 30 |
# File 'lib/request_info/detector_app.rb', line 27 def initialize(app) @app = app @analyzer = EnvAnalyzer.new(self.class.detectors || DEFAULT_DETECTORS) end |
Class Attribute Details
.detectors ⇒ Object
Returns the value of attribute detectors.
14 15 16 |
# File 'lib/request_info/detector_app.rb', line 14 def detectors @detectors end |
Instance Attribute Details
#analyzer ⇒ Object (readonly)
Returns the value of attribute analyzer.
17 18 19 |
# File 'lib/request_info/detector_app.rb', line 17 def analyzer @analyzer end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
17 18 19 |
# File 'lib/request_info/detector_app.rb', line 17 def app @app end |
Instance Method Details
#call(env) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/request_info/detector_app.rb', line 32 def call(env) analyzer.analyze(env) analyzer.wrap_app do app.call(env) end end |