-
Notifications
You must be signed in to change notification settings - Fork 229
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
Recursively call attributes #290
Comments
I look for something like that. |
This will be addressed in virtus 2.0 refactoring. |
thanks @solnic ;) |
This would be useful to me as well. IMO Unless 2.0 is right around the corner, but it doesn't look like that's the case. |
@bradrobertson we can add that with a limitation that when there are cross-references it will blow up with a stack too deep. You could use a recursion guard too but that will slow it down. I think it's fine to clearly document it and call it a day. |
It seems like |
looks like this workaround doesn't work anymore require 'virtus'
class User
include Virtus.model
end
User.new.to_json #=> NoMethodError: undefined method `to_json' for #<User:0x007fed648427c8> |
Is there a recommended way to accomplish this? |
Suppose I have a class
Foo
, which has an array ofBar
objects, as follows:Is there a way to retrieve a attributes hash for each
Bar
({ bars: [ {baz:1, bamboo: 2}] }
) when I callFoo#attributes
? Calling attributes gives me this:The text was updated successfully, but these errors were encountered: