Sha256: d2c7b3c711b781ebab4bf422eda81bba725ded0fc19ae47b19e2afc408b69502

Contents?: true

Size: 430 Bytes

Versions: 5

Compression:

Stored size: 430 Bytes

Contents

module Ahoy
  module Controller

    def self.included(base)
      base.helper_method :current_visit
      base.before_filter do
        RequestStore.store[:ahoy_controller] ||= self
      end
    end

    def current_visit
      visit_token = cookies[:ahoy_visit] || request.headers["Ahoy-Visit"]
      if visit_token
        @current_visit ||= Ahoy.visit_model.where(visit_token: visit_token).first
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ahoy_matey-0.1.8 lib/ahoy/controller.rb
ahoy_matey-0.1.7 lib/ahoy/controller.rb
ahoy_matey-0.1.6 lib/ahoy/controller.rb
ahoy_matey-0.1.5 lib/ahoy/controller.rb
ahoy_matey-0.1.4 lib/ahoy/controller.rb