Skip to content

Commit

Permalink
Reorganize comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan De Villa committed Jan 4, 2019
1 parent bbd574a commit 69274e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
40 changes: 20 additions & 20 deletions lib/active_record/attributes_builder_without_table.rb
Original file line number Diff line number Diff line change
@@ -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, {})
Expand Down
6 changes: 3 additions & 3 deletions lib/active_record/connection_adapters/null_adapter.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 8 additions & 8 deletions lib/active_record/connection_adapters/null_schema_cache.rb
Original file line number Diff line number Diff line change
@@ -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)
[]
Expand Down

0 comments on commit 69274e8

Please sign in to comment.