Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
when you do
you apply attr_reader to all objects of that class, but you need that attributes only in one object
some useful docs are here https://ruby-doc.org/ (look for Core API and there for Class, Module, Object, Basic_Object articles)
Hello everyone,
It would be great to get some feedback on this Error Message.
Make sure dynamic attributes don't persist across different instances of GenericEntity objects.
I do not understand what they mean by this. Because when I create different object they do are present because I put all the code running at initialization.
My code so far is:
Additionally do you have any ressources to read about this topic and realted to Ruby?
Many thanks
Faouzi
And reverse logic confirms when I checked the attribute against the instance variable in my sample tests:
Are you 100% sure
@barks
is available as an instance variable ofdog
and not just an attribute?Any resolution? Yeah when I write my own sample test with same params: dog = GenericEntity.new(:barks=>"obnoxiously", :bites=>"mildly", :color=>"black")
After submitted I got such error message:
But I have tried to test all the tests in my local machine, I got the expected results instead of
nil
.I think an example (like you used) that demonstrates the potential issue is a good way to do it. It's marginally more difficult but maybe not enough to change the ranking.
If you wanted to make it more difficult you could come up with some story why you need to reimplement OpenStruct to have read-only attributes, but as it stands it's a good way to show the unintended side effects of metaprogramming!
I really like the idea of making sure attributes don't bleed across instances. I just need to figure out exactly how to word it in the instructions. Also, I think this may increase the difficulty...what do you think the ranking should be with this new test added?
Update: I have added the test, but left the ranking as is for now.
How about adding this to the end of your tests:
I think the description leads you to believe that you're looking for words (as in separated by whitespace) and not just substrings.