Created
December 18, 2014 23:20
-
-
Save jkarmel/fdba4380db69ac353d46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SendAll | |
def send_all(methods_and_args) | |
return self if methods_and_args.empty? | |
method_name, args = methods_and_args.pop | |
result = send method_name, *args | |
result.send_all result, query | |
end | |
end | |
class ActiveRecord::Relation | |
self.instance_eval { include SendAll } | |
end | |
Developer.send_all [ | |
[:with_interest_bucket_ids_including, [1,2,3]], | |
[:with_location_bucket_ids_includint, [3,4,5]] | |
] | |
# This could then be used in controllers to chain scopes depending on a query | |
Developer.send_all developer_params.to_a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment