mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
First try to implement ArraySerializer
This commit is contained in:
@@ -3,10 +3,6 @@ require 'test_helper'
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class AssocationsTest < Minitest::Test
|
||||
def def_serializer(&block)
|
||||
Class.new(ActiveModel::Serializer, &block)
|
||||
end
|
||||
|
||||
class Model
|
||||
def initialize(hash={})
|
||||
@attributes = hash
|
||||
@@ -26,19 +22,7 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
end
|
||||
Post = Class.new(Model)
|
||||
Comment = Class.new(Model)
|
||||
PostSerializer = Class.new(ActiveModel::Serializer) do
|
||||
attributes :title, :body
|
||||
|
||||
has_many :comments
|
||||
end
|
||||
|
||||
CommentSerializer = Class.new(ActiveModel::Serializer) do
|
||||
attributes :id, :body
|
||||
|
||||
belongs_to :post
|
||||
end
|
||||
|
||||
def setup
|
||||
@post = Post.new({ title: 'New Post', body: 'Body' })
|
||||
|
||||
Reference in New Issue
Block a user