Algoliasearch-rails: how to `add_index` in multiple models

We have two models and would like to add the same attributes from each model to an Algolia index:

Table A: id, title, description
Table B: id, title, description

Our Algolia table will have two fields: title, description

Both tables already have an algoliasearch block, so we need to use an add_index block in each model to add the model’s data to the Algolia table. I thought I could do something like this:

module SharedSearch
  include AlgoliaSearch

  def self.options
	    index_name: "Animals",

  def self.add_index
    algoliasearch add_index options[:index_name], options do
    	attribute :title :description
    	searchableAttributes %w{title description}

But it’s not clear how we can pass a model to SharedSearch.add_index successfully.

How can we write this add_index functionality without duplicating the same code in each model? Any help with this would be greatly appreciated!