You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your class example in the README missing some things?
# A Post model serializer, using ::ToJson::Serializer inheritanceclassPostSerializer < ::ToJson::SerializerincludePostSerialization# override the serialize method and use the ToJson DSL# any arguments passed to encode! or json! are passed into serializedefserialize(model)put_post_nestedmodelendend# A Post collection serializer using include ToJson::Serialize approachclassPostsSerializerincludePostSerializationdefserialize(collection)put_postscollectionendend# define a module so we can mixin Post model serialization concernsanywhereandavoidtemporaryserializerobjectsforcollectionitemsmodulePostSerializationinclude ::ToJson::Serialize# formatting helperdeffullname(*names)names.join(' ')enddefput_post(post)put:title,post.titleput:body,post.bodyput:author,fullname(post.author.first_name,post.author.last_name)put:comments,CommentsSerializer.new(post.comments)enddefput_post_nested(post)put:postdoput_post(post)endenddefserialize_posts(posts)put:metadoput:total_entries,posts.total_entriesput:total_pages,posts.total_pagesendput:collection,postsdo |post|
put_postpostendendend
Should PostsSerializer be inheriting from ::ToJson::Serializer?
And is put_posts collection, actually serialize_posts?
The text was updated successfully, but these errors were encountered:
Is your class example in the
README
missing some things?Should
PostsSerializer
be inheriting from::ToJson::Serializer
?And is
put_posts collection
, actuallyserialize_posts
?The text was updated successfully, but these errors were encountered: