Sha256: 25d3ce2e4206787ae4999cc40e835c5fe7c37c2e0742fb7340a4afbac36773fa

Contents?: true

Size: 816 Bytes

Versions: 15

Compression:

Stored size: 816 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 %{
        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

15 entries across 15 versions & 1 rubygems

Version Path
ahoy_matey-1.6.0 lib/ahoy/model.rb
ahoy_matey-1.5.5 lib/ahoy/model.rb
ahoy_matey-1.5.4 lib/ahoy/model.rb
ahoy_matey-1.5.3 lib/ahoy/model.rb
ahoy_matey-1.5.2 lib/ahoy/model.rb
ahoy_matey-1.5.1 lib/ahoy/model.rb
ahoy_matey-1.5.0 lib/ahoy/model.rb
ahoy_matey-1.4.2 lib/ahoy/model.rb
ahoy_matey-1.4.1 lib/ahoy/model.rb
ahoy_matey-1.4.0 lib/ahoy/model.rb
ahoy_matey-1.3.1 lib/ahoy/model.rb
ahoy_matey-1.3.0 lib/ahoy/model.rb
ahoy_matey-1.2.2 lib/ahoy/model.rb
ahoy_matey-1.2.1 lib/ahoy/model.rb
ahoy_matey-1.2.0 lib/ahoy/model.rb