Class: ActiveRecordDataLoader::ActiveRecord::ColumnDataProvider
- Inherits:
-
Object
- Object
- ActiveRecordDataLoader::ActiveRecord::ColumnDataProvider
- Defined in:
- lib/active_record_data_loader/active_record/column_data_provider.rb
Constant Summary collapse
- VALUE_GENERATORS =
{ enum: EnumValueGenerator, integer: IntegerValueGenerator, string: TextValueGenerator, text: TextValueGenerator, datetime: DatetimeValueGenerator, }.freeze
Class Method Summary collapse
- .provider_for(model_class:, ar_column:, connection_factory:) ⇒ Object
- .supported?(model_class:, ar_column:) ⇒ Boolean
Class Method Details
.provider_for(model_class:, ar_column:, connection_factory:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_record_data_loader/active_record/column_data_provider.rb', line 15 def provider_for(model_class:, ar_column:, connection_factory:) raise_error_if_not_supported(model_class, ar_column) { ar_column.name.to_sym => VALUE_GENERATORS[column_type(ar_column)].generator_for( model_class: model_class, ar_column: ar_column, connection_factory: connection_factory ), } end |
.supported?(model_class:, ar_column:) ⇒ Boolean
27 28 29 30 31 |
# File 'lib/active_record_data_loader/active_record/column_data_provider.rb', line 27 def supported?(model_class:, ar_column:) return false if model_class.reflect_on_association(ar_column.name) VALUE_GENERATORS.keys.include?(column_type(ar_column)) end |