Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize temporal classes of subclasses #39

Merged
merged 2 commits into from
Oct 19, 2024

Conversation

doits
Copy link
Contributor

@doits doits commented Apr 18, 2024

history classes where not correctly initialized in such a case:

class User
end

class BigUser < User
end

User.history.last # => exception if it is a BigUserHistory without this patch

@doits doits force-pushed the fix_sti_init branch 2 times, most recently from f493db2 to ede0eb3 Compare April 24, 2024 14:49
history classes where not correctly initialized in such a case:

```rb
class User
end

class BigUser < User
end

User.history.last # => exception if it is a BigUserHistory without this patch
```
@doits
Copy link
Contributor Author

doits commented Apr 24, 2024

While working on a spec I realized that my first attempt fixed the error only if the subclass was already loaded, which it might not be the case when initializing the history class of the superclass, e.g.:

# without eager loading

FlyingMachine.subclasses # => []
# FlyingMachine.history would not init BroomHistory in this case with my old fix

Broom
# subclass is loaded now

FlyingMachine.subclasses # => [Broom]
# FlyingMachine.history would init BroomHistory if it was called after this point *for the first time*

Therefore I changed the fix to work differently and now it always works (and I added a spec).

What do you think about it?

@doits doits mentioned this pull request Apr 26, 2024
@evman182 evman182 requested a review from bkroeker April 29, 2024 01:25
@bkroeker bkroeker merged commit 6afd324 into bkroeker:master Oct 19, 2024
19 checks passed
@bkroeker
Copy link
Owner

Thank you!

@doits doits deleted the fix_sti_init branch November 28, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants