Class: WURFL::Middleware
- Inherits:
-
Object
- Object
- WURFL::Middleware
- Defined in:
- lib/wurfl-lite-middleware.rb,
lib/wurfl-lite-middleware/version.rb
Constant Summary collapse
- VERSION =
"1.0.7"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/wurfl-lite-middleware.rb', line 6 def initialize( app, = {} ) @app = app # Try to get the location from either parameters or environment location = .delete(:wurfl_xml) || ENV['WURFL_XML'] @wurfl = location.nil? ? WURFL.new : WURFL.new( location ) # Configure the object @wurfl.match_threshold = [:match_threshold] if [:match_threshold] end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 |
# File 'lib/wurfl-lite-middleware.rb', line 16 def call( env ) env['WURFL'] = @wurfl[ env[ 'HTTP_USER_AGENT' ] ] @app.call( env ) end |