Sha256: 0e106e0f3e67944bd5772361c6eb5f4f104f6cea500441d19c4256f4f689a921

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Ahoy
  module Stores
    class BaseStore

      def initialize(options)
        @options = options
      end

      def track_visit(options)
      end

      def track_event(name, properties, options)
      end

      def visit
      end

      def authenticate(user)
        @user = user
        if visit and visit.respond_to?(:user) and !visit.user
          visit.user = user
          visit.save!
        end
      end

      def report_exception(e)
      end

      def user
        @user ||= controller.current_user
      end

      def exclude?
        bot?
      end

      def generate_id
        SecureRandom.uuid
      end

      protected

      def bot?
        @bot ||= Browser.new(ua: request.user_agent).bot?
      end

      def request
        @request ||= @options[:request] || controller.try(:request)
      end

      def controller
        @controller ||= @options[:controller]
      end

      def ahoy
        @ahoy ||= @options[:ahoy]
      end

      def visit_properties
        ahoy.visit_properties
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ahoy_matey-1.0.1 lib/ahoy/stores/base_store.rb
ahoy_matey-1.0.0 lib/ahoy/stores/base_store.rb