-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Idea] Remove InstanceMethods mixin #606
Comments
You want to dynamically define ~60 instance methods we currently have? Do you realize how terrible it's gonna look?
As I said here: if you need multiple ancestries (do you?), you should definitely use another approach to ancestry - separate table (like closure_tree or your own implementation). It will be much faster and convenient to use.
What exactly is broken? Have you looked inside
How's that? With ~60 dynamic definitions you'll lose much more than you'll gain from removing a few |
Well, this was on my mind and I wanted to document it.
You are right. That is a lot.
I do wonder about this, I think they could look similar enough: def subtree depth_options = {}
self.ancestry_base_class.ordered_by_ancestry.scope_depth(depth_options, depth).subtree_of(self)
end
define_ancestry_method("subtree", "depth_options={}") do
"self.class.order_by_ancestry(#{ancestry_column}).scope_depth(depth_options, depth).subtree_of(self)"
end This would be a pain to debug. (debugging rails code is often a pain with basic methods) I also think the methods could be defined in a way that allows for extensibility like updates to column caches and the like.
Probably not. As a first step, I probably need to see if I could get the ancestry column out of the class methods in the first place.
Agreed. I do have one case where I could use this, and our solution has not been the best but we are not in a hurry to change it. It is confusing and not necessary. |
update:
|
A user has submitted bugs when using an ancestry column other than |
Documenting an idea for changing the way ancestry is mixed into the code.
Instead of including a static set of classes that use class level variables, it would dynamically define those methods using class level helpers and passing in all values of interest.
This basically follows the way that rails defines attributes and associations.
This will:
send(ancestry_column)
calls (which I do worry are currently a little broken)ancestry_base_class
.Before
After
send
orbase_class.send
.send(ancestry_column)
. Since rails has been tuning this for years, using their method seems like a safe bet and it will leverage any speedups they make in the future. (need to verify)The text was updated successfully, but these errors were encountered: