-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add scope to unique #2471
Conversation
# @return [self] | ||
def unique(max_retries = 10_000) | ||
@unique ||= UniqueGenerator.new(self, max_retries) | ||
def unique(max_retries = 10_000, scope: DefaultUniqueScope) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
Heyo @bradleesand, are you still interested in working on this PR? Thanks! |
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. |
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. |
Issue#
No-Story
Description:
Adds an optional
scope
parameter to theunique
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.)