Sha256: 7b54038d7a53d0597c07c14c45f0d816598a73e4c500be139dd8390de3ce30a9

Contents?: true

Size: 995 Bytes

Versions: 4

Compression:

Stored size: 995 Bytes

Contents

module NativeGapController

    extend ActiveSupport::Concern

    included do
        before_action :set_nativegap
    end

    def set_nativegap_user
        current_user if current_user
    end

    private

    def set_nativegap
        platform = params[:nativegap]
        if platform && NativeGap.configuration.send(platform)
            id = cookies[:nativegapAppId]
            url = request.original_url.split('?').first
            @app = NativeGap::App.find_by(id: id, platform: platform, url: url) if id && NativeGap::App.where(id: id, platform: platform, url: url).any?

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

            cookies[:nativegapAppId] = @app.id
            cookies[:nativegapApp] = url
        end
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nativegap-3.0.3 app/controllers/concerns/native_gap_controller.rb
nativegap-3.0.2 app/controllers/concerns/native_gap_controller.rb
nativegap-3.0.1 app/controllers/concerns/native_gap_controller.rb
nativegap-3.0.0 app/controllers/concerns/native_gap_controller.rb