Skip to content
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

Add scope to unique #2471

Closed

Conversation

bradleesand
Copy link

Issue#

No-Story

Description:

Adds an optional scope parameter to the unique method. This can be useful if you are using the same generator for multiple unique scope and don't want to run out of unique values. (Like, if you're using Pokemon names in every factory and running out of names.)

# @return [self]
def unique(max_retries = 10_000)
@unique ||= UniqueGenerator.new(self, max_retries)
def unique(max_retries = 10_000, scope: DefaultUniqueScope)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the scope is a class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope can be just be a string or symbol. If desired a Faker::DEFAULT_UNIQUE_SCOPE contant could be set instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I prefer Symbol
to save memory

# @return [self]
def unique(max_retries = 10_000)
@unique ||= UniqueGenerator.new(self, max_retries)
def unique(max_retries = 10_000, scope: DefaultUniqueScope)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope can be just be a string or symbol. If desired a Faker::DEFAULT_UNIQUE_SCOPE contant could be set instead.

@Zeragamba
Copy link
Contributor

Heyo @bradleesand, are you still interested in working on this PR? Thanks!

@Zeragamba
Copy link
Contributor

Closing PR for now due to being almost a month stale. Feel free to comment if you're still planing on working on this and we'll reopen it.

@Zeragamba Zeragamba closed this Sep 23, 2022
@bradleesand
Copy link
Author

I'm no longer working in Ruby on the daily but I'd be happy to finish it up because this change was really useful to me in my old job.

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

Successfully merging this pull request may close these issues.

4 participants