Sha256: ce7b5e1e2374a8cda64315a68b8123d49c298a086da5fa59853291730c4a3f07

Contents?: true

Size: 496 Bytes

Versions: 4

Compression:

Stored size: 496 Bytes

Contents

module Rack
  module Schmobile
    module Request
      def is_mobile?
        if @is_mobile.nil?
          @is_mobile = Rack::Schmobile::Filters.apply(self)
        end

        @is_mobile
      end

      def toggle_mobile_session!
        session[Rack::Schmobile::IS_MOBILE] = !is_mobile?
        @is_mobile = nil
      end

      def is_device?(identifier)
        user_agent =~ /#{identifier}/i
      end
    end
  end
end

Rack::Request.class_eval do
  include Rack::Schmobile::Request
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
schmobile-0.4.1 lib/rack/schmobile/request_extension.rb
schmobile-0.4.0 lib/rack/schmobile/request_extension.rb
schmobile-0.3.2 lib/rack/schmobile/request_extension.rb
schmobile-0.3.1 lib/rack/schmobile/request_extension.rb