meilisearch-ruby icon indicating copy to clipboard operation
meilisearch-ruby copied to clipboard

Improve the gem's public api by removing the bang operator in some methods

Open brunoocasali opened this issue 4 years ago • 0 comments

Original discussion https://github.com/meilisearch/meilisearch-ruby/pull/273/files#r779759981

Today we use !(bang) operator in some particular cases eg. create_index!, add_documents!, these methods have something in common, they wait for the task completion.

After v0.25.0 index creations are totally async, so they respond with a task object not an index anymore. Anyway, what is the real problem here is the usage of bang makes a lot of difference and the typing structure is close to the other methods.

You could type create_index and get a task as a response, or
You could type create_index! and get an index as a response.

The proposal here is to remove this syntax in order to provide something more clear to prevent such mistakes like:

create_index('movies', sync: true), create_index('movies', wait: true), create_index('movies', wait_for_completion: true), in a way that if we don’t pass such param we know that it will respond with default task object.

brunoocasali avatar Jan 12 '22 11:01 brunoocasali