Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle :if => :predicate? methods like :if => :predicate #351

Open
ajsharp opened this issue May 8, 2019 · 0 comments
Open

Handle :if => :predicate? methods like :if => :predicate #351

ajsharp opened this issue May 8, 2019 · 0 comments

Comments

@ajsharp
Copy link

ajsharp commented May 8, 2019

  • Rails version: 5.2.3
  • Algolia Rails integration version: 1.22.0
  • Algolia Client Version: 1.26.0
  • Language Version: 2.5.5

Description

This library has some logic where, if your indexing is conditioned on a particular attribute, the library will figure out if that attribute value has changed, and add/delete the object in algolia appropriately. However, I had some code like this, and this functionality wasn't working:

algoliasearch :if => :active? do
# ...
end

After digging through the library, I realized it wasn't working because of this code:

method_name = "#{attr_name}_changed?"

If you mistakenly pass do :if => :active? instead of :if => :active, this line will check for a method called active?_changed?, which obviously doesn't exist. It would be great if this library should automatically handle predicate methods that are aliases for attribute methods.

Happy to contribute a PR to add this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant