-
Notifications
You must be signed in to change notification settings - Fork 41
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
How to inherit common attributes from a base class? #80
Comments
This is something that hasn't worked, it's been a bit tricky to get right in my first attempts. |
@awendt, I got this working with a module and composition instead of inheritance.
It might not be the inheritance that you're looking for, and so for making hirearchical classes it might not work great, but personally, I think multiple levels of inheritance is a, code smell so this might 🤞 lead to better design |
@awood45 I agree with @awendt that the current inheritance behavior runs counter to what you would expect from rails class conventions. It's possible to change by making the Is there any interest in pursuing that route? |
* Aws Record models can now be extended using standard ruby inheritance (#80). Co-authored-by: Juli Tera <terajul@amazon.com>
I have 2 models that share a number of attributes, but have some of their own. Is there any way I can use this library to do this?
If I put the
include
on the super class:Then either
Dog.new
orCat.new
raises:If I move
include Aws::Record
into the subclasses, loadingAnimal
stops working.If I
include Aws::Record
in all 3 classes, the subclasses don't inherit attributes because of the wayAws::Record::Attributes.included
works.I can make this work using:
but doing this feels like having to work around the library's limitations. Is there a better way?
The text was updated successfully, but these errors were encountered: