Sha256: 28bdee321443d9d4da719c8a315f2fdf156133e2dc48b4e8ff876fba31f5e79e

Contents?: true

Size: 366 Bytes

Versions: 17

Compression:

Stored size: 366 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} ||= Ahoy.instance.try(:visit_or_create)
        end
      }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ahoy_matey-5.3.0 lib/ahoy/model.rb
ahoy_matey-5.2.1 lib/ahoy/model.rb
ahoy_matey-5.2.0 lib/ahoy/model.rb
ahoy_matey-5.1.0 lib/ahoy/model.rb
ahoy_matey-5.0.2 lib/ahoy/model.rb
ahoy_matey-5.0.1 lib/ahoy/model.rb
ahoy_matey-5.0.0 lib/ahoy/model.rb
ahoy_matey-4.2.1 lib/ahoy/model.rb
ahoy_matey-4.2.0 lib/ahoy/model.rb
ahoy_matey-4.1.0 lib/ahoy/model.rb
ahoy_matey-4.0.3 lib/ahoy/model.rb
ahoy_matey-4.0.2 lib/ahoy/model.rb
ahoy_matey-4.0.1 lib/ahoy/model.rb
ahoy_matey-4.0.0 lib/ahoy/model.rb
ahoy_matey-3.3.0 lib/ahoy/model.rb
ahoy_matey-3.2.0 lib/ahoy/model.rb
ahoy_matey-3.1.0 lib/ahoy/model.rb