Sha256: 19f52b760e54c0da4457bd31778ecc5278df37207cb7fb14967176e61901af5e

Contents?: true

Size: 772 Bytes

Versions: 22

Compression:

Stored size: 772 Bytes

Contents

module Workarea
  class Segment
    module Rules
      class TrafficReferrer < Base
        field :medium, type: String
        field :source, type: Array, default: []
        field :url, type: String

        def qualifies?(visit)
          medium_match?(visit.referrer) ||
            source_match?(visit.referrer) ||
            url_match?(visit.referrer)
        end

        def medium_match?(referrer)
          medium.present? && medium.to_s.strip.casecmp?(referrer.medium.to_s)
        end

        def source_match?(referrer)
          source.any? { |s| s.present? && s.to_s.strip.casecmp?(referrer.source.to_s) }
        end

        def url_match?(referrer)
          url.present? && referrer.uri.to_s =~ /#{url.strip}/i
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.26 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.25 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.23 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.22 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.21 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.20 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.19 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.18 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.17 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.16 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.15 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.14 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.13 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.12 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.11 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.10 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.9 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.8 app/models/workarea/segment/rules/traffic_referrer.rb
workarea-core-3.5.7 app/models/workarea/segment/rules/traffic_referrer.rb