Just a heads up here, this blows up if you are using the Array[MyVirtusModel] type.
You can bypass this via:
class ModelCollection < Array
def to_h
map { |model|
model.to_h
}
end
end
class Image
include Virtus.model
attribute :width, Integer
attribute :height, Integer
attribute :url, String
end
class Album
include Virtus.model
attribute :id, String
attribute :title, String
attribute :type, String
attribute :images, ModelCollection[Image]
end
Just a heads up here, this blows up if you are using the
Array[MyVirtusModel]
type.You can bypass this via: