Sha256: 2da3f0c3fc877fd002745fb80550a10e99ec56d17a57a3161d28a9cef5162765
Contents?: true
Size: 1007 Bytes
Versions: 5
Compression:
Stored size: 1007 Bytes
Contents
# encoding: utf-8 # # This file is part of the brauser gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>. # 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 ||= 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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
brauser-1.0.7 | lib/brauser/hooks.rb |
brauser-1.0.6 | lib/brauser/hooks.rb |
brauser-1.0.5 | lib/brauser/hooks.rb |
brauser-1.0.1 | lib/brauser/hooks.rb |
brauser-1.0.0 | lib/brauser/hooks.rb |