ActiveModel::Serializers::JSON support roles

I think this would be useful, but I'm not sure that this just means that there shouldn't be two serailizers instead of putting both in one class.

Steve, are you thinking about something like this in terms of code?

render json: SearchClient.new(@clients)

#or

render json: ContractWon.new(@clients)

class SearchClient

def initialize(clients)

@clients = clients

end

def to_json(options=nil)

@clients.to_json(only: %w(foo bar)

end

end

class ContractWon

def initialize(clients)

@clients = clients

end

def to_json(options=nil)

@clients.to_json(only: %w(baz other)

end

end

That’s basically the approach I’ve been using lately, and it works quite fine for my needs :).