<commit_before>module Facebook
  module Messenger
    module Incoming
      # Referral class represents an incoming Facebook Messenger referral event.
      #
      # @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_referrals
      class Referral
        include Facebook::Messenger::Incoming::Common

        # The referral portion of the payload.
        class Referral
          def initialize(referral)
            @referral = referral
          end

          # Return String of ref data set in referrer.
          def ref
            @referral['ref']
          end

          # Return String of referral source.
          def source
            @referral['source']
          end

          # Return String of referral type.
          def type
            @referral['type']
          end

          # Return String of ad id.
          def ad_id
            @referral['ad_id']
          end
        end<commit_msg>check for prescence of ad_id on the hash before getting it<commit_after>module Facebook
  module Messenger
    module Incoming
      # Referral class represents an incoming Facebook Messenger referral event.
      #
      # @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_referrals
      class Referral
        include Facebook::Messenger::Incoming::Common

        # The referral portion of the payload.
        class Referral
          def initialize(referral)
            @referral = referral
          end

          # Return String of ref data set in referrer.
          def ref
            @referral['ref']
          end

          # Return String of referral source.
          def source
            @referral['source']
          end

          # Return String of referral type.
          def type
            @referral['type']
          end

          # Return String of ad id.
          def ad_id
            @referral['ad_id'] if @referral.key?('ad_id')
          end
        end
{'fraction_non_alphanumeric': 0.06343656343656344, 'fraction_numerical': 0.0, 'mean_word_length': 1.6849865951742626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2968647', 'n_tokens_mistral': 510, 'n_tokens_neox': 477, 'n_words': 159}