Sha256: 910ea4c5ac3ac8b7259a99b95a56c494cf824c355dffd4a5de9aa16f8ab64133

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

module Native
    class PlatformsController < ApplicationController

        def android
            set_app 'android'
            redirect_to send(Native.configuration.android_url)
        end

        def ios
            set_app 'ios'
            redirect_to send(Native.configuration.ios_url)
        end

        def uwp
            set_app 'uwp'
            redirect_to send(Native.configuration.uwp_url)
        end

        def chrome
            set_app 'chrome'
            redirect_to send(Native.configuration.chrome_url)
        end

        def osx
            set_app 'osx'
            redirect_to send(Native.configuration.osx_url)
        end

        def win32
            set_app 'win32'
            redirect_to send(Native.configuration.win32_url)
        end

        def win64
            set_app 'win64'
            redirect_to send(Native.configuration.win64_url)
        end

        def lin32
            set_app 'lin32'
            redirect_to send(Native.configuration.lin32_url)
        end

        def lin64
            set_app 'lin64'
            redirect_to send(Native.configuration.lin64_url)
        end

        private

        def set_app platform
            id = cookies[:nativeAppId]
            url = request.original_url[0...-( platform.length + 1 )]
            @app = Native::App.find_by(id: id, platform: platform, url: url) if id && Native::App.where(id: id, platform: platform, url: url).any?

            if @app.nil?
                @app = Native::App.new
                @app.platform = platform
                @app.url = url
            end
            @app.owner = set_app_owner
            @app.last_used = Time.now
            @app.save!

            cookies[:nativeAppId] = @app.id
            cookies[:nativePlatform] = platform
            cookies[:nativeApp] = url
        end

    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
native-2.1.4 app/controllers/native/platforms_controller.rb
native-2.1.3 app/controllers/native/platforms_controller.rb