Class: Drummond

Inherits:
Object
  • Object
show all
Defined in:
lib/drummond.rb,
lib/drummond/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, debug = false, encoding = :url_encoded, adapter = Faraday.default_adapter) ⇒ Drummond

Returns a new instance of Drummond.



7
8
9
10
11
12
13
14
# File 'lib/drummond.rb', line 7

def initialize url, debug=false, encoding=:url_encoded, adapter=Faraday.default_adapter
  @debug = debug
  @conn = Faraday.new(:url => url) do |faraday|
    faraday.request encoding 
    faraday.response :logger if @debug
    faraday.adapter adapter 
  end
end

Instance Attribute Details

#connObject

Returns the value of attribute conn.



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

def conn
  @conn
end

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

Instance Method Details

#delete(path, params = {}, headers = {}) ⇒ Object



28
29
30
# File 'lib/drummond.rb', line 28

def delete path, params = {}, headers = {}
  self.request path, 'delete', params, headers
end

#get(path, params = {}, headers = {}) ⇒ Object



16
17
18
# File 'lib/drummond.rb', line 16

def get path, params = {}, headers = {}
  self.request path, 'get', params, headers
end

#post(path, params = {}, headers = {}) ⇒ Object



20
21
22
# File 'lib/drummond.rb', line 20

def post path, params = {}, headers = {}
  self.request path, 'post', params, headers
end

#put(path, params = {}, headers = {}) ⇒ Object



24
25
26
# File 'lib/drummond.rb', line 24

def put path, params = {}, headers = {}
  self.request path, 'put', params, headers
end