Class: ActiveRecordDataLoader::ActiveRecord::IntegerValueGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_data_loader/active_record/integer_value_generator.rb

Class Method Summary collapse

Class Method Details

.generator_for(model_class:, ar_column:, connection_factory: nil) ⇒ Object



7
8
9
10
11
# File 'lib/active_record_data_loader/active_record/integer_value_generator.rb', line 7

def generator_for(model_class:, ar_column:, connection_factory: nil)
  range_limit = [((256**number_of_bytes(ar_column)) / 2) - 1, 1_000_000_000].min

  -> { rand(0..range_limit) }
end