Skip to content

Commit e5d0f5b

Browse files
committed
Update documentation after rebase: add WHY comments for PSQL_META_COMMANDS
1 parent 746c272 commit e5d0f5b

File tree

7 files changed

+198
-1640
lines changed

7 files changed

+198
-1640
lines changed

CLAUDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This branch contains v3 (current stable release). A v4 refactor with different a
5555

5656
**Trade-off**: Not fiber-safe, but works for 99% of Rails deployments.
5757

58-
**See**: `lib/apartment/tenant.rb:22-45`, `docs/architecture.md`
58+
**See**: `Apartment::Tenant.adapter` method in `tenant.rb`, `docs/architecture.md`
5959

6060
### 2. Block-Based Tenant Switching
6161

@@ -65,7 +65,7 @@ This branch contains v3 (current stable release). A v4 refactor with different a
6565

6666
**Alternative rejected**: Manual switch/reset - too error-prone.
6767

68-
**See**: `lib/apartment/adapters/abstract_adapter.rb:86-98`
68+
**See**: `AbstractAdapter#switch` method in `adapters/abstract_adapter.rb`
6969

7070
### 3. Excluded Models
7171

@@ -75,7 +75,7 @@ This branch contains v3 (current stable release). A v4 refactor with different a
7575

7676
**Limitation**: Can't use `has_and_belongs_to_many` - must use `has_many :through`.
7777

78-
**See**: `lib/apartment/adapters/abstract_adapter.rb:108-114`
78+
**See**: `AbstractAdapter#process_excluded_models` method in `adapters/abstract_adapter.rb`
7979

8080
### 4. Adapter Pattern
8181

@@ -93,7 +93,7 @@ This branch contains v3 (current stable release). A v4 refactor with different a
9393

9494
**Implementation**: ActiveSupport::Callbacks on `:create` and `:switch`.
9595

96-
**See**: `lib/apartment/adapters/abstract_adapter.rb:7-8`
96+
**See**: Callback definitions in `AbstractAdapter` class in `adapters/abstract_adapter.rb`
9797

9898
## File Organization
9999

@@ -115,7 +115,7 @@ This branch contains v3 (current stable release). A v4 refactor with different a
115115

116116
**Environment isolation**: Optional `prepend_environment`/`append_environment` to prevent cross-environment tenant name collisions.
117117

118-
**See**: `lib/apartment.rb:126-143` for implementation
118+
**See**: `Apartment.extract_tenant_config` method in `lib/apartment.rb`
119119

120120
## Common Pitfalls
121121

docs/architecture.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Apartment v3 uses **thread-local state** for tenant tracking. Each thread mainta
4747

4848
**Alternative considered**: Global state with mutex locking. Rejected due to contention and complexity.
4949

50-
**See**: `lib/apartment/tenant.rb:22-45` - adapter method
50+
**See**: `Apartment::Tenant.adapter` method in `tenant.rb`
5151

5252
### 4. Callback Pattern
5353

@@ -57,7 +57,7 @@ Apartment v3 uses **thread-local state** for tenant tracking. Each thread mainta
5757

5858
**Use cases**: Logging, notifications, analytics, APM integration.
5959

60-
**See**: `lib/apartment/adapters/abstract_adapter.rb:7-8`
60+
**See**: Callback definitions in `AbstractAdapter` class
6161

6262
### 5. Strategy Pattern (Elevators)
6363

@@ -95,7 +95,7 @@ Apartment v3 uses **thread-local state** for tenant tracking. Each thread mainta
9595

9696
3. **Transaction handling**: Detect existing transactions (RSpec). Why? Avoid nested transactions that PostgreSQL rejects.
9797

98-
**See**: `lib/apartment/adapters/abstract_adapter.rb:23-36` - create method
98+
**See**: `AbstractAdapter#create` method
9999

100100
### Configuration Resolution
101101

@@ -105,7 +105,7 @@ Apartment v3 uses **thread-local state** for tenant tracking. Each thread mainta
105105

106106
**Critical handling**: Rescue `ActiveRecord::StatementInvalid` during boot. Why? Table might not exist yet (migrations pending). Return empty array to allow app to start.
107107

108-
**See**: `lib/apartment.rb:126-143` - extract_tenant_config
108+
**See**: `Apartment.extract_tenant_config` method
109109

110110
## Data Flow Differences by Database
111111

@@ -195,7 +195,7 @@ Apartment v3 uses **thread-local state** for tenant tracking. Each thread mainta
195195

196196
**Limitation**: `has_and_belongs_to_many` doesn't work with excluded models. Must use `has_many :through` instead.
197197

198-
**See**: `lib/apartment/adapters/abstract_adapter.rb:108-114` - process_excluded_models
198+
**See**: `AbstractAdapter#process_excluded_models` method
199199

200200
## Configuration Design
201201

@@ -215,7 +215,7 @@ Apartment v3 uses **thread-local state** for tenant tracking. Each thread mainta
215215

216216
**Benefit**: Enables horizontal scaling and geographic distribution.
217217

218-
**See**: README.md examples, `lib/apartment.rb:59-61` - db_config_for
218+
**See**: README.md examples and `Apartment.db_config_for` method
219219

220220
## Performance Design Decisions
221221

0 commit comments

Comments
 (0)