<commit_before>
require 'rubycouch/operations/base'
require 'rubycouch/operations/responses'

class GetDocument

  include QueryStringMixin
  include DatabaseRequestMixin
  include SimpleResponseMixin

  def initialize(doc_id)
    @doc_id = doc_id
  end

  def method
    'GET'
  end

  def rev_id=(rev_id)
    merge_query_items({:rev => rev_id})
  end

  def sub_path
    "/#{@doc_id}"
  end

end

##
# Create or update a document.
#
# For update, rev_id should be supplied. For create, obviously it shouldn't
# be.
class PutDocument

  include QueryStringMixin
  include DatabaseRequestMixin
  include SimpleResponseMixin

  attr_reader :body
  attr_accessor :content_type

  def initialize(doc_id, body)
    @doc_id = doc_id
    @body = body
    @content_type = 'application/json'
  end

  def method
    'PUT'
  end

  def rev_id=(rev_id)
    merge_query_items({:rev => rev_id})
  end

  def sub_path
    "/#{@doc_id}"
  end

end

class DeleteDocument

  include QueryStringMixin
  include DatabaseRequestMixin
  include SimpleResponseMixin<commit_msg>Allow document PUT to be created with a hash<commit_after>
require 'rubycouch/operations/base'
require 'rubycouch/operations/responses'

class GetDocument

  include QueryStringMixin
  include DatabaseRequestMixin
  include SimpleResponseMixin

  def initialize(doc_id)
    @doc_id = doc_id
  end

  def method
    'GET'
  end

  def rev_id=(rev_id)
    merge_query_items({:rev => rev_id})
  end

  def sub_path
    "/#{@doc_id}"
  end

end

##
# Create or update a document.
#
# For update, rev_id should be supplied. For create, obviously it shouldn't
# be.
#
# The body can be supplied as a string, or something JSON.dump() can process
# into a string.
class PutDocument

  include QueryStringMixin
  include DatabaseRequestMixin
  include SimpleResponseMixin

  attr_reader :body
  attr_accessor :content_type

  def initialize(doc_id, body)
    @doc_id = doc_id
    @body = if body.is_a? String then body else JSON.dump(body) end
    @content_type = 'application/json'
  end

  def method
    'PUT'
  end

  def rev_id=(rev_id)
    merge_query_items({:rev => rev_id})
  end

  def sub_path
    "/#{@doc_id}"
  end

end

class DeleteDocument

  include QueryStringMixin
  include DatabaseRequestMixin
  include SimpleResponseMixin
{'fraction_non_alphanumeric': 0.07467248908296943, 'fraction_numerical': 0.0, 'mean_word_length': 3.704312114989733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7469756', 'n_tokens_mistral': 778, 'n_tokens_neox': 755, 'n_words': 216}