Sha256: a1f80ffe476b0bbe257ced96eed40a99991b53634b3ee96405c5bb79d2f068ff

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

module Ahoy
  module Model

    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 %Q{
        def set_visit
          self.#{name} ||= RequestStore.store[:ahoy].try(:visit)
        end
      }
    end

    # deprecated

    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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ahoy_matey-1.1.1 lib/ahoy/model.rb
ahoy_matey-1.1.0 lib/ahoy/model.rb
ahoy_matey-1.0.2 lib/ahoy/model.rb
ahoy_matey-1.0.1 lib/ahoy/model.rb