You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: helpers.rb
    path of file: ./repos/webmachine-ruby/lib/webmachine/decision
    
    the code of the file until where you have to start completion: require 'stringio'
require 'time'
require 'webmachine/streaming'
require 'webmachine/media_type'
require 'webmachine/quoted_string'
require 'webmachine/etags'
require 'webmachine/header_negotiation'
require 'webmachine/constants'

module Webmachine
  module Decision
    # Methods that assist the Decision {Flow}.
    module Helpers
      include QuotedString
      include Streaming
      include HeaderNegotiation

      # Determines if the response has a body/entity set.
      def has_response_body?
        !response.body.nil? && !response.body.empty?
      end

      # If the response body exists, encode it.
      # @see #encode_body
      def encode_body_if_set
        encode_body if has_response_body?
      end

      # Encodes the body in the selected charset and encoding
    
      def encode_body
        body = response.body
        chosen_charset = metadata[CHARSET]
        chosen_encoding = metadata[CONTENT_ENCODING]
        charsetter = resource.charsets_provided&.find { |c, _| c == chosen_charset }&.last || :charset_nop
        encoder = resource.encodings_provided[chosen_encoding]
        response.body = case body
        when String # 1.8 treats Strings as Enumerable
          resource.send(encoder, resource.send(charsetter, body))
        when IO, StringIO
          IOEncoder.new(resource, encoder, charsetter, body)
        when Fiber
          FiberEncoder.new(resource, encoder, charsetter, body)
        when Enumerable
          EnumerableEncoder.new(resource, encoder, charsetter, body)
        else
          if body.respond_to?(:call)
            CallableEncoder.new(resource, encoder, charsetter, body)
          else
            resource.send(encoder, resource.send(charsetter, body))
          end