Module: RackHtml5RailsHelper

Defined in:
lib/rack-html5-rails_helper.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Defines a method and a helper for each header the rack-html5 gem sets. Example: browser_supports_canvas? will return true if the HTTP_X_SUPPORTS_HTML5_CANVAS header is set.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rack-html5-rails_helper.rb', line 11

def self.included(base)
  features = [:wysiwyg, :classname, :elements, :canvas, :messaging, :audio, :video, :textapi, :draganddrop, :offline, :forms, :svg]
  
  features.each do |header|    
    method_name = "browser_supports_#{header}?".to_sym
    define_method method_name do
      request.headers.has_key?("HTTP_X_SUPPORTS_HTML5_#{header.to_s.upcase}")    
    end
        
    base.send(:helper_method, method_name)
  end
end