Class: WithUid::UidGenerator Private
- Inherits:
-
Object
- Object
- WithUid::UidGenerator
- Includes:
- Enumerable
- Defined in:
- lib/with_uid/uid_generator.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #context ⇒ Object readonly private
- #generator ⇒ Object readonly private
Instance Method Summary collapse
- #each {|uid(prefix)| ... } ⇒ Object private
-
#initialize(context, **options, &generator) ⇒ UidGenerator
constructor
private
A new instance of UidGenerator.
- #prefix ⇒ Object private
- #suffix ⇒ Object private
Constructor Details
#initialize(context, **options, &generator) ⇒ UidGenerator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of UidGenerator.
10 11 12 13 14 15 |
# File 'lib/with_uid/uid_generator.rb', line 10 def initialize(context, ** , &generator) @context = context @generator = generator @suffix = [:suffix] @prefix = [:prefix] end |
Instance Attribute Details
#context ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/with_uid/uid_generator.rb', line 8 def context @context end |
#generator ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/with_uid/uid_generator.rb', line 8 def generator @generator end |
Instance Method Details
#each {|uid(prefix)| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 |
# File 'lib/with_uid/uid_generator.rb', line 17 def each return enum_for(:each) unless block_given? yield uid(prefix) loop do next_uid = uid(prefix, suffix) yield next_uid end end |
#prefix ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 |
# File 'lib/with_uid/uid_generator.rb', line 33 def prefix with_default(@prefix) do '' end end |
#suffix ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 |
# File 'lib/with_uid/uid_generator.rb', line 27 def suffix with_default(@suffix) do "_#{SecureRandom.hex(3)}" end end |