Add Enumerable#uniq? #936

Closed
lighthouse-import opened this Issue May 16, 2011 · 5 comments

Comments

Projects
None yet
1 participant
@lighthouse-import

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6588
Created by Bounga - 2011-03-16 11:17:03 UTC

Checks for Enumerable content uniqueness

Returns true if the collection has no duplicated content.
Can be called with a block too, much like any?, so people.uniq? { |p| p.age > 26 } returns true if only 1 person is over 26.

Unit test are included.

Please test and +1 this useful tiny patch.

@lighthouse-import

This comment has been minimized.

Show comment Hide comment
@lighthouse-import

lighthouse-import May 16, 2011

Imported from Lighthouse.
Comment by Bounga - 2011-03-16 11:28:52 UTC

Github fork / branch is available at https://github.com/Bounga/rails/commits/enumerable_uniq

Imported from Lighthouse.
Comment by Bounga - 2011-03-16 11:28:52 UTC

Github fork / branch is available at https://github.com/Bounga/rails/commits/enumerable_uniq

@lighthouse-import

This comment has been minimized.

Show comment Hide comment
@lighthouse-import

lighthouse-import May 16, 2011

Imported from Lighthouse.
Comment by Bounga - 2011-03-16 12:18:41 UTC

Same one with calculation cache

Imported from Lighthouse.
Comment by Bounga - 2011-03-16 12:18:41 UTC

Same one with calculation cache

@lighthouse-import

This comment has been minimized.

Show comment Hide comment
@lighthouse-import

lighthouse-import May 16, 2011

Imported from Lighthouse.
Comment by Bounga - 2011-03-16 15:17:48 UTC

Better test case for blocks

Imported from Lighthouse.
Comment by Bounga - 2011-03-16 15:17:48 UTC

Better test case for blocks

@lighthouse-import

This comment has been minimized.

Show comment Hide comment
@lighthouse-import

lighthouse-import May 16, 2011

Imported from Lighthouse.
Comment by Ryan Orr - 2011-03-19 18:19:43 UTC

Took a look at the code in the last patch that you posted. I like the implementation but you were missing a test that checked a block that produced a result that wasn't unique. I added a test for this and cleaned up some whitespace errors that I was getting with your patch.

To avoid whitespacing errors in the future try the command:

git diff --check

This will tell you which files are producing whitespace errors if any.

Imported from Lighthouse.
Comment by Ryan Orr - 2011-03-19 18:19:43 UTC

Took a look at the code in the last patch that you posted. I like the implementation but you were missing a test that checked a block that produced a result that wasn't unique. I added a test for this and cleaned up some whitespace errors that I was getting with your patch.

To avoid whitespacing errors in the future try the command:

git diff --check

This will tell you which files are producing whitespace errors if any.

@lighthouse-import

This comment has been minimized.

Show comment Hide comment
@lighthouse-import

lighthouse-import May 16, 2011

Attachments saved to Gist: http://gist.github.com/971817

Attachments saved to Gist: http://gist.github.com/971817

jake3030 pushed a commit to jake3030/rails that referenced this issue Jun 28, 2011

Ensure ActiveRecord::ConnectionPool.connected? handles undefined conn…
…ections. [#936 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment