module Ahoy::Views::Views::ClassMethods

Public Instance Methods

ahoy_views() click to toggle source
# File lib/ahoy/views/views.rb, line 9
def ahoy_views
    before_create :process_view

    belongs_to :visitor, polymorphic: true, optional: true
    belongs_to :visited, polymorphic: true, optional: true

    scope :appearances, -> { where name: 'appearance' }
    scope :views, -> { where name: 'view' }
    scope :visitors, -> { where name: 'visitor' }
    scope :returnees, -> { where name: 'returnee' }
    scope :visited_in_session, -> (visit) { where visit_id: visit.id }
    scope :visited, -> (visitor) { where visitor_id: visitor.id, visitor_type: visitor.class.name }

    include Ahoy::Views::Views::InstanceMethods
end