Class: ActiveRecordDataLoader::ActiveRecord::TextValueGenerator
- Inherits:
-
Object
- Object
- ActiveRecordDataLoader::ActiveRecord::TextValueGenerator
- Defined in:
- lib/active_record_data_loader/active_record/text_value_generator.rb
Constant Summary collapse
- GENERATORS =
{ likely_a_person_full_name?: -> { ActiveRecordDataLoader::DataFaker.person_name }, likely_a_first_name?: -> { ActiveRecordDataLoader::DataFaker.first_name }, likely_a_middle_name?: -> { ActiveRecordDataLoader::DataFaker.middle_name }, likely_a_last_name?: -> { ActiveRecordDataLoader::DataFaker.last_name }, likely_an_organization_name?: -> { ActiveRecordDataLoader::DataFaker.company_name }, }.freeze
Class Method Summary collapse
Class Method Details
.generator_for(model_class:, ar_column:, connection_factory: nil) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/active_record_data_loader/active_record/text_value_generator.rb', line 15 def generator_for(model_class:, ar_column:, connection_factory: nil) scenario = GENERATORS.keys.find { |m| send(m, model_class, ar_column) } generator = GENERATORS.fetch(scenario, -> { SecureRandom.uuid }) -> { truncate_if_needed(generator.call, ar_column.limit) } end |