class ActiveModel::Serializer

def associations(options={})

def associations(options={})
  associations = self.class._associations
  included_associations = filter(associations.keys)
  associations.each_with_object({}) do |(name, association), hash|
    if included_associations.include? name
      if association.embed_ids?
        ids = serialize_ids association
        if association.embed_namespace?
          hash = hash[association.embed_namespace] ||= {}
          hash[association.key] = ids
        else
          hash[association.key] = ids
        end
      elsif association.embed_objects?
        if association.embed_namespace?
          hash = hash[association.embed_namespace] ||= {}
        end
        hash[association.embedded_key] = serialize association, options
      end
    end
  end
end