Sha256: 45cbfb6da3f9fc31a7710c478b4ce1be8c4ebb0657f605e8e0c4fe9d1c650ba0

Contents?: true

Size: 602 Bytes

Versions: 5

Compression:

Stored size: 602 Bytes

Contents

module Ahoy
  module Deckhands
    class UtmParameterDeckhand
      def initialize(landing_page, params = nil)
        @landing_page = landing_page
        @params = params || {}
      end

      def landing_params
        @landing_params ||= begin
          landing_uri = Addressable::URI.parse(@landing_page) rescue nil
          (landing_uri && landing_uri.query_values) || {}
        end
      end

      %w(utm_source utm_medium utm_term utm_content utm_campaign).each do |name|
        define_method name do
          @params[name] || landing_params[name]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ahoy_matey-1.6.1 lib/ahoy/deckhands/utm_parameter_deckhand.rb
ahoy_matey-1.6.0 lib/ahoy/deckhands/utm_parameter_deckhand.rb
ahoy_matey-1.5.5 lib/ahoy/deckhands/utm_parameter_deckhand.rb
ahoy_matey-1.5.4 lib/ahoy/deckhands/utm_parameter_deckhand.rb
ahoy_matey-1.5.3 lib/ahoy/deckhands/utm_parameter_deckhand.rb