-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify is_sharded? calculation further
Instead of checking class inheritance we can just call a class method. This way we can define it to be false for ActiveRecord::Base and override it in sharded subclasses. This also gives us the possibility of using a module (or just plain defining the method in any random class).
- Loading branch information
Showing
2 changed files
with
11 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
module ActiveRecordShards | ||
module Ext | ||
module ShardedModel | ||
def is_sharded? # rubocop:disable Naming/PredicateName | ||
true | ||
end | ||
end | ||
end | ||
|
||
class ShardedModel < ActiveRecord::Base | ||
self.abstract_class = true | ||
|
||
extend ActiveRecordShards::Ext::ShardedModel | ||
end | ||
end |