Skip to content

Commit 8a7de3f

Browse files
authored
feat: export a Sorbet RBI declaring the ActiveRecord::Base mixin (#76)
Journaled mixes AuditLog into ActiveRecord::Base via ActiveSupport.on_load(:active_record), which runtime reflection tools (tapioca) attribute inconsistently depending on host-app load order — some apps' generated journaled RBIs get the mixin, others don't, forcing hand-written shims. Tapioca merges RBI files a gem exports under rbi/ into the RBI it generates, so ship the one declaration reflection loses. The generated module RBI already carries mixes_in_class_methods for ClassMethods/BlockedClassMethods, so has_audit_log/skip_audit_log and the blocked-method guards resolve statically through this single include.
1 parent 864dc7c commit 8a7de3f

6 files changed

Lines changed: 18 additions & 5 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
journaled (6.2.8)
4+
journaled (6.2.9)
55
activejob
66
activerecord
77
activesupport

gemfiles/rails_7_2.gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
journaled (6.2.8)
4+
journaled (6.2.9)
55
activejob
66
activerecord
77
activesupport

gemfiles/rails_8_0.gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
journaled (6.2.8)
4+
journaled (6.2.9)
55
activejob
66
activerecord
77
activesupport

journaled.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
1717
s.license = "MIT"
1818
s.metadata['rubygems_mfa_required'] = 'true'
1919

20-
s.files = Dir["{app,config,db,lib,journaled_schemas}/**/*", "LICENSE", "Rakefile", "README.md"]
20+
s.files = Dir["{app,config,db,lib,journaled_schemas,rbi}/**/*", "LICENSE", "Rakefile", "README.md"]
2121

2222
s.required_ruby_version = ">= 3.2"
2323

lib/journaled/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Journaled
4-
VERSION = "6.2.8"
4+
VERSION = "6.2.9"
55
end

rbi/journaled.rbi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# typed: true
2+
3+
# Journaled mixes AuditLog into every Active Record class at boot via
4+
# `ActiveSupport.on_load(:active_record) { include Journaled::AuditLog }`
5+
# (lib/journaled/audit_log.rb). Runtime reflection tools attribute that mixin
6+
# inconsistently depending on load order — under some hosts it lands in the
7+
# activerecord gem's RBI, under others it is lost entirely — so declare it
8+
# here. Tapioca merges RBI files a gem exports under rbi/ into the RBI it
9+
# generates for the gem, which makes `has_audit_log`, `skip_audit_log`, and
10+
# the blocked-method guards resolve statically in every consuming app.
11+
class ActiveRecord::Base
12+
include Journaled::AuditLog
13+
end

0 commit comments

Comments
 (0)