Skip to content

Add next and previous item methods#20

Merged
pyromaniac merged 8 commits intomongoid:masterfrom
jeremylynch:master
Mar 8, 2014
Merged

Add next and previous item methods#20
pyromaniac merged 8 commits intomongoid:masterfrom
jeremylynch:master

Conversation

@jeremylynch
Copy link
Copy Markdown
Contributor

I have added two more useful methods to move through lists.

item.next_item # returns next item in the list.
item.previous_item # returns previous item in the list.

Readme and tests have been updated and are passing.

Thanks

@pyromaniac
Copy link
Copy Markdown
Collaborator

Specs failed. Also why can't we use something like item.lower_items.first and item.higher_items.last?

@jeremylynch
Copy link
Copy Markdown
Contributor Author

Apologies about the late response. It appears find_by is not supported by mongoid 2, so the specs weren't passing, I have fixed this issue by using a where().first instead. The specs should now pass.

As regards using item.lower_items.first and items.higher_items.last, it's more convenient to use item.next_item and item.previous_item. After all, this gem is about ordering documents, so traversing from one to the next should be convenient, would you agree?

@jeremylynch
Copy link
Copy Markdown
Contributor Author

Ok finally I have worked it all out. The tests aren't passing due to an unrelated test and compatibility with mongoid 4 (you will see that the current build is also failing), i'm not exactly sure what is going wrong but it is worth checking out the Travis CI build. Anyway, the tests for this pull request are passing and it's ready to merge

@jeremylynch
Copy link
Copy Markdown
Contributor Author

Thanks to @pjkelly for his pull request #21, the tests are now passing. This pull request is ready to merge.
What are your thoughts on merging this commit over @pyromaniac? Thanks

pyromaniac added a commit that referenced this pull request Mar 8, 2014
Add next and previous item methods
@pyromaniac pyromaniac merged commit 8b4fffa into mongoid:master Mar 8, 2014
@pyromaniac
Copy link
Copy Markdown
Collaborator

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants