Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make Candidates#each iterable without block. #651

Merged
merged 2 commits into from
May 24, 2015
Merged

Make Candidates#each iterable without block. #651

merged 2 commits into from
May 24, 2015

Conversation

ihnatz
Copy link
Contributor

@ihnatz ihnatz commented Mar 4, 2015

Hi

The mean aim of this commit is to provide access to generated slug candidates without direct AR manipulations

FriendlyId::Candidates.new(model, model.slug_candidates).each 
# => ["ergonomic-zero-es-africa", "ergonomic-zero-es-africa-100"]
# instead of 
# LocalJumpError: no block given (yield)

So, it seems reasonable for me to use this syntax instead of calling #save. It can be written to return Enumerator instead of array, but it will be not so readable and will complicate method.

@parndt
Copy link
Collaborator

parndt commented Mar 4, 2015

Oh, I like this! We'll need tests (please ❤️) to ensure that the functionality works like you say it does now and in the future, though. :)

@ihnatz
Copy link
Contributor Author

ihnatz commented Mar 4, 2015

Ok, no problem

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 99.07% when pulling 307cf17 on ignat-zakrevsky:minor-candidates-each-update into b5290a9 on norman:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 99.07% when pulling 307cf17 on ignat-zakrevsky:minor-candidates-each-update into b5290a9 on norman:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 99.07% when pulling 307cf17 on ignat-zakrevsky:minor-candidates-each-update into b5290a9 on norman:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 99.07% when pulling 307cf17 on ignat-zakrevsky:minor-candidates-each-update into b5290a9 on norman:master.

@ihnatz
Copy link
Contributor Author

ihnatz commented Mar 4, 2015

@parndt, updated

@parndt
Copy link
Collaborator

parndt commented Mar 4, 2015

@norman over to you.

FYI, CI is (and was before this patch) failing due to ActiveRecord 4.2 + postgresql + jruby.. I had a very similar / the same thing happen in awesome_nested_set (commit), though I'm not exactly sure why it fails here.

Here's the awesome_nested_set job

norman added a commit that referenced this pull request May 24, 2015
…date

Make Candidates#each iterable without block.
@norman norman merged commit 7391ac1 into norman:master May 24, 2015
@norman
Copy link
Owner

norman commented May 24, 2015

Merged, thanks!

@norman
Copy link
Owner

norman commented Jun 1, 2015

This is now out in 5.2.0.beta.1. No timetable for stable release yet, but probably within a couple weeks.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants