-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend `ActiveRecord::Base` functionality only after `ActiveRecord` has been fully loaded. Also: - Require Railtie as suggested by APIs - Patch DBConsole only if needed - Move application configuration check in an after initialize lazy load hook to be sure that `Rails.application` is available at the moment of the check Ref: - thoughtbot/factory_bot_rails#426 - https://edgeapi.rubyonrails.org/classes/Rails/Railtie.html#class-Rails::Railtie-label-Creating+a+Railtie Close #231
- Loading branch information
Showing
5 changed files
with
53 additions
and
57 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
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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module ChronoModel | ||
# A module to add to ActiveRecord::Base to check if they are backed by | ||
# temporal tables. | ||
module Chrono | ||
# Checks whether this Active Record model is backed by a temporal table | ||
# | ||
# @return [Boolean] false if the connection does not respond to is_chrono? | ||
# the result of connection.is_chrono?(table_name) otherwise | ||
def chrono? | ||
return false unless connection.respond_to? :is_chrono? | ||
|
||
connection.is_chrono?(table_name) | ||
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'chrono_model/patches/db_console' | ||
|
||
if Rails.version < '6.1' | ||
Rails::DBConsole.prepend ChronoModel::Patches::DBConsole::Config | ||
else | ||
Rails::DBConsole.prepend ChronoModel::Patches::DBConsole::DbConfig | ||
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
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