Sha256: 581eccaaedc65c68563a499556460c5b84044bcaa7524a5ae9bfb911fc42af66
Contents?: true
Size: 374 Bytes
Versions: 6
Compression:
Stored size: 374 Bytes
Contents
module Ahoy module Model def visitable(name = :visit, **options) class_eval do belongs_to(name, class_name: "Ahoy::Visit", optional: true, **options) before_create :set_ahoy_visit end class_eval %{ def set_ahoy_visit self.#{name} ||= Thread.current[:ahoy].try(:visit_or_create) end } end end end
Version data entries
6 entries across 6 versions & 1 rubygems