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

Version Path
embedded_associations-4.1.1 spec/support/serialization_helpers.rb
embedded_associations-4.1.0 spec/support/serialization_helpers.rb
embedded_associations-4.0.0 spec/support/serialization_helpers.rb
embedded_associations-0.0.4 spec/support/serialization_helpers.rb
embedded_associations-0.0.3 spec/support/serialization_helpers.rb
embedded_associations-0.0.2 spec/support/serialization_helpers.rb
embedded_associations-0.0.1 spec/support/serialization_helpers.rb