<commit_before>module Endpoints
  class Exports < Base
    namespace "/exports" do
      before do
        content_type :json, charset: 'utf-8'
      end

      get do
        encode [{ id: "01234567-89ab-cdef-0123-456789abcdef", created_at: '2012-01-01T12:00:00Z', updated_at: '2012-01-01T12:00:00Z', rdio_username: 'nzoschke', state: 'pending' }]
      end

      post do
        e = Export.create(rdio_username: 'nzoschke', state: 'pending')
        e.save
        status 201
        encode Serializers::Export.new(:default).serialize(e)
      end

      get "/:id" do
        e = Export[params[:id]]
        encode Serializers::Export.new(:default).serialize(e)
      end

      patch "/:id" do |id|
        e = Export[params[:id]]
        encode Serializers::Export.new(:default).serialize(e)
      end

      delete "/:id" do |id|
        e = Export[params[:id]]
        e.delete
        encode Serializers::Export.new(:default).serialize(e)
      end
    end
  end
end<commit_msg>serialize method<commit_after>module Endpoints
  class Exports < Base
    namespace "/exports" do
      before do
        content_type :json, charset: 'utf-8'
      end

      def serialize(export)
        Serializers::Export.new(:default).serialize(export)
      end

      get do
        encode [{ id: "01234567-89ab-cdef-0123-456789abcdef", created_at: '2012-01-01T12:00:00Z', updated_at: '2012-01-01T12:00:00Z', rdio_username: 'nzoschke', state: 'pending' }]
      end

      post do
        e = Export.create(rdio_username: 'nzoschke', state: 'pending')
        e.save
        status 201
        encode serialize(e)
      end

      get "/:id" do
        e = Export[params[:id]]
        encode serialize(e)
      end

      patch "/:id" do |id|
        e = Export[params[:id]]
        encode serialize(e)
      end

      delete "/:id" do |id|
        e = Export[params[:id]]
        e.delete
        encode serialize(e)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12628865979381443, 'fraction_numerical': 0.05360824742268041, 'mean_word_length': 2.176759410801964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6240399', 'n_tokens_mistral': 723, 'n_tokens_neox': 631, 'n_words': 148}