-
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.
Merge pull request #232 from ifad/bugfix/231-fix-preload-of-patches
Use Active Support lazy load hooks
- 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