def save_design_doc(data)
      attrs = case data
              when String
                MultiJson.load(data)
              when IO
                MultiJson.load(data.read)
              when Hash
                data
              else
                raise ArgumentError, "Document should be Hash, String or IO instance"
              end
      id = attrs.delete('_id').to_s
      attrs['language'] ||= 'javascript'
      raise ArgumentError, "'_id' key must be set and start with '_design/'." if id !~ /\A_design\//
      res = __http_query(:view, :put, "/#{id}", MultiJson.dump(attrs), 'application/json', nil, nil, nil)
      return true if res[:status] == 201
      val = MultiJson.load(res[:chunks].join)
      raise Error::View.new("save_design_doc", val['error'])
    end
def save_design_doc(data)
      attrs = case data
              when String
                MultiJson.load(data)
              when IO
                MultiJson.load(data.read)
              when Hash
                data
              else
                raise ArgumentError, "Document should be Hash, String or IO instance"
              end
      id = attrs.delete('_id').to_s
      attrs['language'] ||= 'javascript'
      raise ArgumentError, "'_id' key must be set and start with '_design/'." if id !~ /\A_design\//
      res = __http_query(:view, :put, "/#{id}", MultiJson.dump(attrs), 'application/json', nil, nil, nil)
      return true if res[:status] == 201
      val = MultiJson.load(res[:chunks].join)
      raise Error::View.new("save_design_doc", val['error'])
    end
Update or create design doc with supplied views

 @since 1.2.0

 @param [Hash, IO, String] data The source object containing JSON
   encoded design document. It must have +_id+ key set, this key
   should start with +_design/+.

 @return [true, false]