Class: FFakerTW::UniqueUtils
- Inherits:
-
Object
- Object
- FFakerTW::UniqueUtils
show all
- Defined in:
- lib/ffakerTW/utils/unique_utils.rb
Constant Summary
collapse
- RetryLimitExceeded =
Class.new(StandardError)
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(generator, max_retries) ⇒ UniqueUtils
Returns a new instance of UniqueUtils.
6
7
8
9
10
|
# File 'lib/ffakerTW/utils/unique_utils.rb', line 6
def initialize(generator, max_retries)
@generator = generator
@max_retries = max_retries
@previous_results = Hash.new { |hash, key| hash[key] = Set.new }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments) ⇒ Object
12
13
14
|
# File 'lib/ffakerTW/utils/unique_utils.rb', line 12
def method_missing(name, *arguments)
@generator.respond_to?(name) ? add_results_to_hash(name, *arguments) : super
end
|
Class Method Details
.clear ⇒ Object
26
27
28
|
# File 'lib/ffakerTW/utils/unique_utils.rb', line 26
def self.clear
ObjectSpace.each_object(self, &:clear)
end
|
Instance Method Details
#clear ⇒ Object
22
23
24
|
# File 'lib/ffakerTW/utils/unique_utils.rb', line 22
def clear
@previous_results.clear
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
16
17
18
|
# File 'lib/ffakerTW/utils/unique_utils.rb', line 16
def respond_to_missing?(method_name, include_private = false)
super
end
|