Netflix / fast_jsonapi

No Longer Maintained - A lightning fast JSON:API serializer for Ruby Objects.
Apache License 2.0
5.07k stars 425 forks source link

Thoughts on adding a value transform option or a 'type' option to Attribute? #457

Open weilandia opened 4 years ago

weilandia commented 4 years ago

Specifically, I'd like to easily be able to send all id values to the client as strings without having to call to_s on every id attribute and without changing the Rails default of making ids integers.

So, instead of

attribute :contract_id do |obj|
  obj.contract_id.to_s
end

Something like

attribute :contract_id, type: :string

or

attribute :contract_id, coerce: :string