Sha256: 621b70e50ce27dc03a3e8365bd3757c9ad682af3cac4121dcf01ba54968a484b
Contents?: true
Size: 435 Bytes
Versions: 7
Compression:
Stored size: 435 Bytes
Contents
module SerializationHelpers # helper to serialize in a format that would # be passed to the controller from a request # (e.g. from the client) def serialize(model, root=false) options = {} options[:root] = false unless root params = model.active_model_serializer.new(model, options).as_json params[:id] = model.id if root params end def serialize_array(arr) arr.map(&method(:serialize)) end end
Version data entries
7 entries across 7 versions & 1 rubygems