Sha256: 7484d90e4978dffffdec704dabc3d8b52560ca76000f889cf92ed0cfad4cab89

Contents?: true

Size: 522 Bytes

Versions: 1

Compression:

Stored size: 522 Bytes

Contents

module SeparateViews
  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
separate_views-0.2.0 lib/separate_views/base.rb