You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: target.rb
    path of file: ./repos/activity_notification/lib/activity_notification/models/concerns
    
    the code of the file until where you have to start completion: module ActivityNotification
  # Target implementation included in target model to notify, like users or administrators.
  module Target
    extend ActiveSupport::Concern

    included do
      include Common
      include Association

      # Has many notification instances of this target.
      # @scope instance
      # @return [Array<Notificaion>, Mongoid::Criteria<Notificaion>] Array or database query of notifications of this target
      has_many_records :notifications,
        class_name: "::ActivityNotification::Notification",
        as: :target,
        dependent: :delete_all

      class_attribute :_notification_email,
                      :_notification_email_allowed,
                      :_batch_notification_email_allowed,
                      :_notification_subscription_allowed,
    
    
      def arrange_notification_index(loading_unopened_index_method, loading_opened_index_method, options = {})
        # When the target have unopened notifications
        if has_unopened_notifications?(options)
          # Return unopened notifications first
          target_unopened_index = arrange_single_notification_index(loading_unopened_index_method, options)
          # Total limit of notification index
          total_limit = options[:limit] || ActivityNotification.config.opened_index_limit
          # Additionaly, return opened notifications unless unopened index size overs the limit
          if (opened_limit = total_limit - target_unopened_index.size) > 0
            target_opened_index = arrange_single_notification_index(loading_opened_index_method, options.merge(limit: opened_limit))
            target_unopened_index.concat(target_opened_index.to_a)
          else
            target_unopened_index
          end