-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement detection for sti for including subclasses in check (#689)
* Implement detection for sti for including subclasses in check * Lint * use sti_name * Add inverse check for can/cannot on child class
- Loading branch information
Liberatys
authored
Mar 23, 2022
1 parent
c97a152
commit 40bb117
Showing
4 changed files
with
57 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
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class StiDetector | ||
def self.sti_class?(subject) | ||
return false unless defined?(ActiveRecord::Base) | ||
return false unless subject.respond_to?(:descends_from_active_record?) | ||
return false if subject == :all || subject.descends_from_active_record? | ||
return false unless subject < ActiveRecord::Base | ||
|
||
true | ||
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