Module: Ahoy::Model

Defined in:
lib/ahoy/model.rb

Instance Method Summary collapse

Instance Method Details

#ahoy_visitObject

deprecated



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ahoy/model.rb', line 22

def ahoy_visit
  class_eval do
    warn "[DEPRECATION] ahoy_visit is deprecated"

    belongs_to :user, polymorphic: true

    def landing_params
      @landing_params ||= begin
        warn "[DEPRECATION] landing_params is deprecated"
        Deckhands::UtmParameterDeckhand.new(landing_page).landing_params
      end
    end
  end
end

#visitable(name = nil, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ahoy/model.rb', line 3

def visitable(name = nil, options = {})
  if name.is_a?(Hash)
    name = nil
    options = name
  end
  name ||= :visit
  class_eval do
    belongs_to name, options
    before_create :set_visit
  end
  class_eval %{
    def set_visit
      self.#{name} ||= RequestStore.store[:ahoy].try(:visit)
    end
  }
end