Created
March 5, 2014 14:16
-
-
Save Porta/9367970 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class User < Ohm::Model | |
| set :requests, :Request | |
| end | |
| class Request < Ohm::Model | |
| attribute :path | |
| attribute :processed | |
| attribute :origin | |
| index :path | |
| index :processed | |
| end | |
| search = Custom::Search.new("string to search") | |
| ids_found = search.ids | |
| # ids_found == ["1", "3", "5"] | |
| user = User[1] | |
| requests = user.requests | |
| # requests.map(&:id) == ["1", "2", "3", "5", "6", "7"] | |
| #here I would need to remove from requests the ones that DOESN'T match the ids in ids_found | |
| #code continues and I need to apply more filters | |
| if processed | |
| requests.find(processed: true) | |
| end | |
| if path | |
| requests.find(path: path) | |
| end | |
| found = requests.sort(:limit => [0, 50]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment