Items Addressed
New Features
- Ability to handle a top level collection of objects (via autodetect or explicitly) via a singular object decanter. This eliminates the need to define collection decanters and improves developer experience
class TripDecanter < Decanter::Base
input :destination, :string
# ...
end
# Decanting a collection in <= 3.3.0
class TripCollectionDecanter < Decanter::Base
has_many :trips
end
params = { trips_attributes: [{ destination: 'Hawaii' }, { destination: 'Lisbon' }] }
trips = TripCollectionDecanter.decant(params)[:trips_attributes]
# Decanting a collection in >= 3.4.0
params = { trips: [{ destination: 'Hawaii' }, { destination: 'Lisbon' }] }
trips = TripDecanter.decant(params[:trips]))