Sha256: da2f1a4348157692872392abfea43979b9d435ddd2df0bd072559570380b2d9c
Contents?: true
Size: 999 Bytes
Versions: 1
Compression:
Stored size: 999 Bytes
Contents
# # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>. # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php. # module Brauser # A set of Hooks for adding brauser to web frameworks. module Hooks # Hook for integration with Ruby on Rails. module RubyOnRails # Includes brauser in ActionController. # # @param base [Class] The base controller class. def self.included(base) base.send(:helper_method, :browser) end # Detects the current browser. # # @param force [Boolean] If to force detection. # @return [Browser] The detected browser. def browser(force = false) @browser = nil if force @browser ||= ::Brauser::Browser.new(request.headers["User-Agent"], request.headers["Accept-Language"]) end end end end ActionController::Base.send(:include, Brauser::Hooks::RubyOnRails) if defined?(Rails)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
brauser-4.0.0 | lib/brauser/hooks.rb |