Sha256: d77121fd68059aceaec1ee6e9a199f6367732f4fff6b3a63c39cb61ca6f7e1e6

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 Bytes

Contents

module Ahoy
  module ControllerExtensions

    def self.included(base)
      base.helper_method :current_visit
    end

    protected

    def current_visit
      if cookies[:ahoy_visit]
        @current_visit ||= Ahoy::Visit.where(visit_token: cookies[:ahoy_visit]).first
        if @current_visit
          @current_visit
        else
          # clear cookie if visits are destroyed
          cookies.delete(:ahoy_visit)
          nil
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahoy_matey-0.0.3 lib/ahoy/controller_extensions.rb