Module: Brauser::Hooks::RubyOnRails

Defined in:
lib/brauser/hooks.rb

Overview

Hook for integration with Ruby on Rails.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(base)

Includes brauser in ActionController.

Parameters:

  • base (Class)

    The base controller class.



15
16
17
# File 'lib/brauser/hooks.rb', line 15

def self.included(base)
  base.send(:helper_method, :browser)
end

Instance Method Details

- (Browser) browser(force = false)

Detects the current browser.

Parameters:

  • force (Boolean) (defaults to: false)

    If to force detection.

Returns:

  • (Browser)

    The detected browser.



23
24
25
26
# File 'lib/brauser/hooks.rb', line 23

def browser(force = false)
  @browser = nil if force
  @browser ||= Browser.new(request.headers["User-Agent"], request.headers["Accept-Language"])
end