Class: Couch::Server

Inherits:
Object
  • Object
show all
Includes:
BasicRequest, BasicRequest::Get, BasicRequest::Head, BulkRequest::Delete, BulkRequest::Get, BulkRequest::Post
Defined in:
lib/couch.rb

Defined Under Namespace

Classes: Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BulkRequest::Post

#post_bulk, #post_bulk_if_big_enough, #post_bulk_throttled

Methods included from BulkRequest::Delete

#bulk_delete

Methods included from BulkRequest::Get

#all_docs, #all_ids, #docs_for_view, #get_all_docs, #get_all_ids, #get_docs_for_view, #get_rows_for_view, #rows_for_view

Methods included from BasicRequest::Get

#get_attachment_str, #get_doc

Methods included from BasicRequest::Head

#get_rev

Methods included from BasicRequest

#create_postfix

Constructor Details

#initialize(url, options) ⇒ Server

Returns a new instance of Server.



276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/couch.rb', line 276

def initialize(url, options)
  if url.is_a? String
    url = URI(url)
  end
  @couch_url = url
  @options = options
  @options[:couch_url] = @couch_url
  @options[:use_ssl] ||= true
  @options[:max_array_length] ||= 250
  @options[:flush_size_mb] ||= 10
  @options[:open_timeout] ||= 5*30
  @options[:read_timeout] ||= 5*30
  @options[:fail_silent] ||= false
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



274
275
276
# File 'lib/couch.rb', line 274

def options
  @options
end

Instance Method Details

#delete(uri) ⇒ Object



291
292
293
294
295
# File 'lib/couch.rb', line 291

def delete(uri)
  Request.new(Net::HTTP::Delete.new(uri), nil,
              @options
  ).perform
end

#get(uri) ⇒ Object



311
312
313
314
315
316
# File 'lib/couch.rb', line 311

def get(uri)
  Request.new(
      Net::HTTP::Get.new(uri), nil,
      @options
  ).perform
end

#head(uri) ⇒ Object



301
302
303
304
305
# File 'lib/couch.rb', line 301

def head(uri)
  Request.new(Net::HTTP::Head.new(uri), nil,
              @options
  ).perform
end

#new_delete(uri) ⇒ Object



297
298
299
# File 'lib/couch.rb', line 297

def new_delete(uri)
  Request.new(Net::HTTP::Delete.new(uri)).couch_url(@couch_url)
end

#new_get(uri) ⇒ Object



318
319
320
# File 'lib/couch.rb', line 318

def new_get(uri)
  Request.new(Net::HTTP::Get.new(uri)).couch_url(@couch_url)
end

#new_head(uri) ⇒ Object



307
308
309
# File 'lib/couch.rb', line 307

def new_head(uri)
  Request.new(Net::HTTP::Head.new(uri)).couch_url(@couch_url)
end

#new_post(uri) ⇒ Object



338
339
340
# File 'lib/couch.rb', line 338

def new_post(uri)
  Request.new(Net::HTTP::Post.new(uri)).couch_url(@couch_url)
end

#new_put(uri) ⇒ Object



328
329
330
# File 'lib/couch.rb', line 328

def new_put(uri)
  Request.new(Net::HTTP::Put.new(uri)).couch_url(@couch_url)
end

#post(uri, json) ⇒ Object



332
333
334
335
336
# File 'lib/couch.rb', line 332

def post(uri, json)
  Request.new(Net::HTTP::Post.new(uri), json,
              @options
  ).perform
end

#put(uri, json) ⇒ Object



322
323
324
325
326
# File 'lib/couch.rb', line 322

def put(uri, json)
  Request.new(Net::HTTP::Put.new(uri), json,
              @options
  ).perform
end