Module: Rbkb::Http::CommonInterface

Included in:
Base, Body, Headers, Parameters, RequestAction, ResponseStatus
Defined in:
lib/rbkb/http/common.rb

Instance Method Summary collapse

Instance Method Details

#_common_init(raw = nil, opts = nil) {|_self| ... } ⇒ Object

This provides a common method for use in ‘initialize’ to slurp in opts parameters and optionally capture a raw blob. This method also accepts a block to which it yields ‘self’

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
13
# File 'lib/rbkb/http/common.rb', line 8

def _common_init(raw=nil, opts=nil)
  self.opts = opts
  yield self if block_given?
  capture(raw) if raw
  return self
end

#optsObject

Implements a common interface for an opts hash which is stored internally as the class variable @opts.

The opts hash is designed to contain various named values for configuration, etc. The values and names are determined entirely by the class that uses it.



21
22
23
# File 'lib/rbkb/http/common.rb', line 21

def opts
  @opts
end

#opts=(o = nil) ⇒ Object

Implements a common interface for setting a new opts hash containing various named values for configuration, etc. This also performs a minimal sanity check to ensure the object is a Hash.



28
29
30
31
# File 'lib/rbkb/http/common.rb', line 28

def opts=(o=nil)
  raise "opts must be a hash" unless (o ||= {}).is_a? Hash
  @opts = o
end