require "mongoid"

module Devops
  module Model
    class Statistic

      include ::Mongoid::Document
      include ::Mongoid::Timestamps::CreatedInt
      include ::ActiveModel::Validations

      store_in collection: "statistic"

      field :user, type: String
      field :path, type: String
      field :method, type: String
      field :body, type: String
      field :response_code, type: Integer

      def to_hash
        hash = self.attributes.clone
        hash["id"] = hash.delete("_id").to_s
        hash
      end
    end
  end
end

