Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your change
This change implements a Plug and Adapter for the ORM's supported by the algoliasearch-rails gem.
When the adapter is required we should invoke
DatabaseAdapter.class_method_defined_within(*args)
which is the Plug class.This should pass this on to the required adapter. The required adapter must also implement this method e.g.
DatabaseAdapter::RequiredAdapter.class_method_defined_within(*args)
.Main
DatabaseAdapter
is a plug for various orm adapter classesDatabaseAdapter::ActiveRecord
DatabaseAdapter::Sequel
DatabaseAdapter::Mongoid
DatabaseAdapter
implements logic for determining which ORM adapter should be usedTest
/spec/algoliasearch/database_adaper_spec.rb
/spec/algoliasearch/database_adapter/active_record_spec.rb
/spec/algoliasearch/database_adapter/sequel_spec.rb
/spec/algoliasearch/database_adapter/mongoid_spec.rb
spec/spec_helper.rb
What problem is this fixing?
#62 is correct, the codebase is very hard to read for new contributors and difficult in general because of various methods implemented for different ORM's.
This change will reduce the amount of complexity in the main
algoliasearch-rails.rb
and will also provide a separation of concerns for ORM's.