-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add extended state machines compiler
- Loading branch information
1 parent
6735573
commit 4e92728
Showing
7 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
boba (0.0.2) | ||
boba (0.0.5) | ||
sorbet-static-and-runtime (~> 0.5) | ||
tapioca (~> 0.16.2) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
# frozen_string_literal: true | ||
|
||
module Boba | ||
VERSION = "0.0.4" | ||
VERSION = "0.0.5" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# typed: ignore | ||
# frozen_string_literal: true | ||
|
||
return unless defined?(Tapioca) | ||
|
||
require "tapioca/dsl/compilers/state_machines" | ||
|
||
module Tapioca | ||
module Dsl | ||
module Compilers | ||
# `Tapioca::Dsl::Compilers::StateMachinesExtended` extends the default state machines compiler provided by Tapioca | ||
# to allow for calling `with_state` and `without_state` on all Active Record relations. This is a temporary fix | ||
# until a more durable solution can be found for this type of issue. | ||
# See https://github.com/Shopify/tapioca/pull/1994#issuecomment-2302624697. | ||
class StateMachinesExtended < ::Tapioca::Dsl::Compilers::StateMachines | ||
ACTIVE_RECORD_RELATION_MODULE_NAMES = [ | ||
"GeneratedRelationMethods", | ||
"GeneratedAssociationRelationMethods", | ||
].freeze | ||
|
||
def decorate | ||
return if constant.state_machines.empty? | ||
|
||
super() | ||
|
||
root.create_path(T.unsafe(constant)) do |klass| | ||
class_module_name = "StateMachineClassHelperModule" | ||
|
||
ACTIVE_RECORD_RELATION_MODULE_NAMES.each do |module_name| | ||
klass.create_module(module_name).create_include(class_module_name) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## StateMachinesExtended | ||
|
||
`Tapioca::Dsl::Compilers::StateMachinesExtended` extends the default state machines compiler provided by Tapioca | ||
to allow for calling `with_state` and `without_state` on all Active Record relations. This is a temporary fix | ||
until a more durable solution can be found for this type of issue. | ||
See https://github.com/Shopify/tapioca/pull/1994#issuecomment-2302624697. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters