Module: Ahoy::Controller
- Defined in:
- lib/ahoy/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #ahoy ⇒ Object
- #current_visit ⇒ Object
- #set_ahoy_cookies ⇒ Object
- #set_ahoy_request_store ⇒ Object
- #track_ahoy_visit ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ahoy/controller.rb', line 5 def self.included(base) base.helper_method :current_visit base.helper_method :ahoy if base.respond_to?(:before_action) 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 else base.before_filter :set_ahoy_cookies, unless: -> { Ahoy.api_only } base.before_filter :track_ahoy_visit, unless: -> { Ahoy.api_only } base.before_filter :set_ahoy_request_store end end |
Instance Method Details
#ahoy ⇒ Object
19 20 21 |
# File 'lib/ahoy/controller.rb', line 19 def ahoy @ahoy ||= Ahoy::Tracker.new(controller: self) end |
#current_visit ⇒ Object
23 24 25 |
# File 'lib/ahoy/controller.rb', line 23 def current_visit ahoy.visit end |
#set_ahoy_cookies ⇒ Object
27 28 29 30 |
# File 'lib/ahoy/controller.rb', line 27 def ahoy. ahoy. end |
#set_ahoy_request_store ⇒ Object
38 39 40 |
# File 'lib/ahoy/controller.rb', line 38 def set_ahoy_request_store RequestStore.store[:ahoy] ||= ahoy end |
#track_ahoy_visit ⇒ Object
32 33 34 35 36 |
# File 'lib/ahoy/controller.rb', line 32 def track_ahoy_visit if ahoy.new_visit? ahoy.track_visit(defer: !Ahoy.track_visits_immediately) end end |