forked from tslocke/hobo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix STI migrations. Fixes doctest, and hopefully ticket #397.
- Loading branch information
1 parent
2e28dbb
commit 03c514b
Showing
2 changed files
with
12 additions
and
2 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 |
---|---|---|
|
@@ -15,8 +15,13 @@ module HoboFields | |
# and speeds things up a little. | ||
inheriting_cattr_reader :field_specs => HashWithIndifferentAccess.new | ||
|
||
# is true if is the base for STI | ||
def self.inheritance_base? | ||
This comment has been minimized.
Sorry, something went wrong.
tslocke
|
||
@is_inheritance_base | ||
end | ||
|
||
def self.inherited(klass) | ||
@is_inheritance_base = true | ||
fields do |f| | ||
f.field(inheritance_column, :string) | ||
end | ||
|
1 comment
on commit 03c514b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some digging before committing. The only thing I found was “superclass”. So I almost used (m.superclass==models_by_table_name[m.table_name].superclass.superclass) as the test, but I wasn’t convinced it was as robust.
Coding style – prefer || over ‘or’ as ‘or’ has very low precedence. I think of ‘or’ as a control flow operator.
Could use ||= as the assignment to simplify?