lib/test_ids.rb in test_ids-0.8.0 vs lib/test_ids.rb in test_ids-0.8.1

- old
+ new

@@ -28,14 +28,21 @@ { bin: opts[:bin], bin_size: opts[:bin_size], softbin: opts[:softbin], softbin_size: opts[:softbin_size], number: opts[:number], number_size: opts[:number_size] } end - # Load an existing allocator, which will be loaded with an empty configuration + # Load an existing allocator, which will be loaded with a configuration based on what has + # been serialized into the database if present, otherwise it will have an empty configuration. + # Returns nil if the given database can not be found. # @api internal def load_allocator(id = nil) - Configuration.new(id).allocator + f = TestIds.database_file(id) + if File.exist?(f) + a = Configuration.new(id).allocator + a.load_configuration_from_store + a + end end def current_configuration configuration(@configuration_id) end @@ -155,9 +162,13 @@ end unless [true, false].include?(val) fail 'TestIds.publish must be set to either true or false' end @publish = val ? :save : :dont_save + end + + def next_in_range(range, options) + current_configuration.allocator.next_in_range(range, options) end ## When set to true, all numbers generated will be checked to see if they comply ## with the current configuration, and if not they will be re-assigned based on the ## current configuration