class ActiveRecord::TableMetadata
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_record/table_metadata.rbs class ActiveRecord::TableMetadata def associated_with?: (String table_name) -> nil def initialize: (Class klass, Arel::Nodes::TableAlias arel_table, ?ActiveRecord::Reflection::BelongsToReflection reflection) -> void def predicate_builder: () -> untyped def reflect_on_aggregation: (String aggregation_name) -> nil def type: (String column_name) -> (ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter | ActiveModel::Type::String) end
:nodoc:
def associated_table(table_name)
def associated_table(table_name) reflection = klass._reflect_on_association(table_name) || klass._reflect_on_association(table_name.singularize) if !reflection && table_name == arel_table.name return self end if reflection association_klass = reflection.klass unless reflection.polymorphic? elsif block_given? association_klass = yield table_name end if association_klass arel_table = association_klass.arel_table arel_table = arel_table.alias(table_name) if arel_table.name != table_name TableMetadata.new(association_klass, arel_table, reflection) else type_caster = TypeCaster::Connection.new(klass, table_name) arel_table = Arel::Table.new(table_name, type_caster: type_caster) TableMetadata.new(nil, arel_table, reflection) end end
def associated_with?(table_name)
Experimental RBS support (using type sampling data from the type_fusion
project).
def associated_with?: (String table_name) -> nil
This signature was generated using 5 samples from 1 application.
def associated_with?(table_name) klass&._reflect_on_association(table_name) || klass&._reflect_on_association(table_name.singularize) end
def has_column?(column_name)
def has_column?(column_name) klass&.columns_hash.key?(column_name) end
def initialize(klass, arel_table, reflection = nil)
Experimental RBS support (using type sampling data from the type_fusion
project).
def initialize: (Class klass, Arel::Nodes::TableAlias arel_table, ?ActiveRecord::Reflection::BelongsToReflection reflection) -> void
This signature was generated using 1 sample from 1 application.
def initialize(klass, arel_table, reflection = nil) @klass = klass @arel_table = arel_table @reflection = reflection end
def polymorphic_association?
def polymorphic_association? reflection&.polymorphic? end
def predicate_builder
Experimental RBS support (using type sampling data from the type_fusion
project).
def predicate_builder: () -> untyped
This signature was generated using 1 sample from 1 application.
def predicate_builder if klass predicate_builder = klass.predicate_builder.dup predicate_builder.instance_variable_set(:@table, self) predicate_builder else PredicateBuilder.new(self) end end
def primary_key
def primary_key klass&.primary_key end
def reflect_on_aggregation(aggregation_name)
Experimental RBS support (using type sampling data from the type_fusion
project).
def reflect_on_aggregation: (String aggregation_name) -> nil
This signature was generated using 1 sample from 1 application.
def reflect_on_aggregation(aggregation_name) klass&.reflect_on_aggregation(aggregation_name) end
def through_association?
def through_association? reflection&.through_reflection? end
def type(column_name)
Experimental RBS support (using type sampling data from the type_fusion
project).
def type: (String column_name) -> (ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter | ActiveModel::Type::String)
This signature was generated using 7 samples from 1 application.
def type(column_name) arel_table.type_for_attribute(column_name) end