Class: Vertebrae::API

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/api.rb

Constant Summary

Constants included from Request

Request::METHODS, Request::METHODS_WITH_BODIES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Request

#delete_request, #get_request, #patch_request, #post_request, #put_request, #request

Constructor Details

#initialize(options = {}, &block) ⇒ API

Create new API



9
10
11
12
13
14
15
16
# File 'lib/api.rb', line 9

def initialize(options={}, &block)
  options.merge!(default_options)

  yield_or_eval(&block) if block_given?
  self.connection = Connection.new(options)
  self.connection.configuration.process_basic_auth(options[:basic_auth])
  setup
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



5
6
7
# File 'lib/api.rb', line 5

def connection
  @connection
end

Instance Method Details

#default_optionsObject



21
22
23
# File 'lib/api.rb', line 21

def default_options
  {}
end

#setupObject



18
19
# File 'lib/api.rb', line 18

def setup
end

#yield_or_eval(&block) ⇒ Object



25
26
27
28
# File 'lib/api.rb', line 25

def yield_or_eval(&block)
  return unless block
  block.arity > 0 ? yield(self) : self.instance_eval(&block)
end