-
Notifications
You must be signed in to change notification settings - Fork 0
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
Gimme some sugar? #3
Comments
I like these ideas. Maybe we should also make it an Enumerable if we are defining each anyway. By the way, we are already defining a "fields" methods that is essentially the "keys" methods. I guess we can alias |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe we can make interacting with this library a little bit sweeter with some convenience methods.
This is a discussion, not a request for changes...yet.
Ideas:
1:
Iterate over response docs from the response object.
If we have a response object
response = Primo.find("otters")
currently we have to navigate to the docs attribute to iterate over the docs
response.docs.each {|d| puts d.title }
Would be simpler to just iterate directly from the response object, and would hide some of the internal details about the object.
response.each {|d| puts d.title }
2: Not so sure about this one
Expose the top level keys of the JSON response in the response object.
Currently we have to go
response.response.keys
to get the top level structure of the json response, which is["highlights", "docs", "timelog", "lang3", "info", "facets", "beaconO22"]
I found it useful when trying to understand what data was available in the response to see what else I might want to dig into.
3: Add some convenience methods for number of results, paging, etc.
Instead of
response.info.total
we justresponse.total
.Same for
response.info.first
,response.info.last
etc.The text was updated successfully, but these errors were encountered: