Sha256: 3f0b7ae594df376dfea266a7f2e628c5cc0a5d3d611f784d81d229ec66a59af2
Contents?: true
Size: 854 Bytes
Versions: 2
Compression:
Stored size: 854 Bytes
Contents
require "request_store" module Ahoy module Controller def self.included(base) if base.respond_to?(:helper_method) base.helper_method :current_visit base.helper_method :ahoy end base.before_action :set_ahoy_cookies, unless: -> { Ahoy.api_only } base.before_action :track_ahoy_visit, unless: -> { Ahoy.api_only } base.before_action :set_ahoy_request_store end def ahoy @ahoy ||= Ahoy::Tracker.new(controller: self) end def current_visit ahoy.visit end def set_ahoy_cookies ahoy.set_visitor_cookie ahoy.set_visit_cookie end def track_ahoy_visit if ahoy.new_visit? ahoy.track_visit(defer: Ahoy.server_side_visits != true) end end def set_ahoy_request_store RequestStore.store[:ahoy] ||= ahoy end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ahoy_matey-2.0.2 | lib/ahoy/controller.rb |
ahoy_matey-2.0.1 | lib/ahoy/controller.rb |