Sha256: b3048464664e89727e60057c46e6ee5e3a9692f23b91239814303ab58f193794

Contents?: true

Size: 520 Bytes

Versions: 1

Compression:

Stored size: 520 Bytes

Contents

module Separation
  module Base
    class << self
      def included(base)
        base.send(:before_action, :set_variant)
      end
    end

    private

    def set_variant
      request.variant = variant
    end

    def variant
      case request.user_agent
      when /iPhone/i
        :phone
      when /iPad/i
        :tablet
      when /Android/i && /mobile/i
        :phone
      when /Android/i
        :tablet
      when /Windows Phone/i
        :phone
      else
        :desktop
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
separation-0.3.0 lib/separation/base.rb