From 69274e8f6341c3fa7b3ae2a9f089bc66af407bb7 Mon Sep 17 00:00:00 2001 From: Ryan De Villa Date: Fri, 4 Jan 2019 14:21:29 -0500 Subject: [PATCH] Reorganize comments --- .../attributes_builder_without_table.rb | 40 +++++++++---------- .../connection_adapters/null_adapter.rb | 6 +-- .../connection_adapters/null_schema_cache.rb | 16 ++++---- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/active_record/attributes_builder_without_table.rb b/lib/active_record/attributes_builder_without_table.rb index 1cd7bf4..07a235a 100644 --- a/lib/active_record/attributes_builder_without_table.rb +++ b/lib/active_record/attributes_builder_without_table.rb @@ -1,26 +1,26 @@ # frozen_string_literal: true +# This class exists to support the use of `find_by_sql` on BaseWithoutTable +# instances. It is highly aware of internal implementation details of +# ActiveRecord. +# +# It ensures that Attributes that have been decorated +# (e.g. with time zone conversion decorators) at class method evaluation +# time do not lose their decoration when BaseWithoutTable instances are +# brought to life via `#instantiate` (by way of `#find_by_sql`). +# +# This occurs when ActiveRecord needs to synthesize Attributes for +# `additional_types` that are not part of the record's schema, which may +# result from joining in columns from an associated relation in a raw SQL +# query. +# +# Since the NullSchemaCache declares that the record has no schema, +# all `additional_types` are in need of an Attribute to represent them. +# However, creating them would clobber the Attributes that were already +# constructed in the evaluation of the `BaseWithoutTable::column` +# class method, and remove the decoration that was applied to them at that +# time. module ActiveRecord - # This class exists to support the use of `find_by_sql` on BaseWithoutTable - # instances. It is highly aware of internal implementation details of - # ActiveRecord. - # - # It ensures that Attributes that have been decorated - # (e.g. with time zone conversion decorators) at class method evaluation - # time do not lose their decoration when BaseWithoutTable instances are - # brought to life via `#instantiate` (by way of `#find_by_sql`). - # - # This occurs when ActiveRecord needs to synthesize Attributes for - # `additional_types` that are not part of the record's schema, which may - # result from joining in columns from an associated relation in a raw SQL - # query. - # - # Since the NullSchemaCache declares that the record has no schema, - # all `additional_types` are in need of an Attribute to represent them. - # However, creating them would clobber the Attributes that were already - # constructed in the evaluation of the `BaseWithoutTable::column` - # class method, and remove the decoration that was applied to them at that - # time. class AttributesBuilderWithoutTable < SimpleDelegator def build_from_database(values = {}, additional_types = {}) super(values, {}) diff --git a/lib/active_record/connection_adapters/null_adapter.rb b/lib/active_record/connection_adapters/null_adapter.rb index 3a977e0..c7e31df 100644 --- a/lib/active_record/connection_adapters/null_adapter.rb +++ b/lib/active_record/connection_adapters/null_adapter.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true +# This class is a concrete implementation of ConnectionAdapters::AbstractAdapter +# that eliminates all code paths attempting to open a connection to a real +# database backend. module ActiveRecord module ConnectionAdapters - # This class is a concrete implementation of ConnectionAdapters::AbstractAdapter - # that eliminates all code paths attempting to open a connection to a real - # database backend. class NullAdapter < SimpleDelegator def schema_cache NullSchemaCache.new diff --git a/lib/active_record/connection_adapters/null_schema_cache.rb b/lib/active_record/connection_adapters/null_schema_cache.rb index 04bb695..c275756 100644 --- a/lib/active_record/connection_adapters/null_schema_cache.rb +++ b/lib/active_record/connection_adapters/null_schema_cache.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true +# When run against a real database backend, ordinarily the SchemaCache +# would open a connection to the DB and attempt to retrieve schema +# information from it. +# +# Here, we declare that these ActiveRecord classes do not have any +# database-backed schema or column information. The structure of an +# ActiveRecord::BaseWithoutTable is purely an in-memory construct +# and is defined through the use of the `column` class methods. module ActiveRecord module ConnectionAdapters - # When run against a real database backend, ordinarily the SchemaCache - # would open a connection to the DB and attempt to retrieve schema - # information from it. - # - # Here, we declare that these ActiveRecord classes do not have any - # database-backed schema or column information. The structure of an - # ActiveRecord::BaseWithoutTable is purely an in-memory construct - # and is defined through the use of the `column` class methods. class NullSchemaCache def columns(*args) []