Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. module SendAll
  2. def send_all(methods_and_args)
  3. return self if methods_and_args.empty?
  4. method_name, args = methods_and_args.pop
  5. result = send method_name, *args
  6. result.send_all result, query
  7. end
  8. end
  9.  
  10. class ActiveRecord::Relation
  11. self.instance_eval { include SendAll }
  12. end
  13.  
  14. Developer.send_all [
  15. [:with_interest_bucket_ids_including, [1,2,3]],
  16. [:with_location_bucket_ids_includint, [3,4,5]]
  17. ]
  18.  
  19. # This could then be used in controllers to chain scopes depending on a query
  20. Developer.send_all developer_params.to_a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement