Sha256: 6dd77a7f7f6c124399d6121a079ede91cc52b0dcff19383dbd76e4840fa18485

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

require "addressable/uri"
require "browser"
require "geocoder"
require "referer-parser"
require "request_store"
require "ahoy/version"
require "ahoy/controller"
require "ahoy/model"
require "ahoy/engine"

module Ahoy

  def self.visit_model
    ::Visit
  end

end

ActionController::Base.send :include, Ahoy::Controller
ActiveRecord::Base.send(:extend, Ahoy::Model) if defined?(ActiveRecord)

if defined?(Warden)
  Warden::Manager.after_authentication do |user, auth, opts|
    request = Rack::Request.new(auth.env)
    if request.cookies["ahoy_visit"]
      visit = Ahoy.visit_model.where(visit_token: request.cookies["ahoy_visit"]).first
      if visit
        visit.user = user
        visit.save!
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahoy_matey-0.1.0 lib/ahoy_matey.rb