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

ReactiveRecord::Collection#any? breaks cases with args/block passed in #215

Closed
adamcreekroad opened this issue Jul 11, 2019 · 0 comments
Closed

Comments

@adamcreekroad
Copy link
Contributor

In the latest release, this method was updated to be smarter and only load the count instead of all the records. But, the case of passing args/block to this method was missed and breaks that functionality. It should now check if args/block has been passed in, and if so then call super and use normal functionality; otherwise use the optimized way of check if the count is positive:

module ReactiveRecord
  class Collection
    def any?(*args, &block)
      # If we are doing anything other than just checking if there is an object in the collection,
      # proceed to the normal behavior
      return super if args&.length&.positive? || block.present?

      # Otherwise just check the count for efficiency
      count.positive?
    end
  end
end
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