Sha256: a0f02179afd7b02bdd2eaf2908c4c4b3b230e0004d53e754ef025f6f716ac478

Contents?: true

Size: 428 Bytes

Versions: 1

Compression:

Stored size: 428 Bytes

Contents

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

      @is_mobile
    end

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schmobile-1.0.0 lib/schmobile/request_extension.rb