Skip to content

Gimme some sugar? #3

@bibliotechy

Description

@bibliotechy

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 just response.total.
Same for response.info.first, response.info.last etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions