Class: Grendel::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/grendel/client.rb

Defined Under Namespace

Classes: HTTPException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri, options = {}) ⇒ Client

Create a new Grendel client instance



8
9
10
11
12
# File 'lib/grendel/client.rb', line 8

def initialize(base_uri, options = {})
  @base_uri = base_uri
  @debug = options[:debug]
  @debug_output = options[:debug_output] || $stderr
end

Instance Attribute Details

#base_uriObject (readonly)

Returns the value of attribute base_uri.



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

def base_uri
  @base_uri
end

#debugObject

Returns the value of attribute debug.



4
5
6
# File 'lib/grendel/client.rb', line 4

def debug
  @debug
end

#debug_outputObject

Returns the value of attribute debug_output.



4
5
6
# File 'lib/grendel/client.rb', line 4

def debug_output
  @debug_output
end

Instance Method Details

#delete(uri, options = {}) ⇒ Object



30
31
32
# File 'lib/grendel/client.rb', line 30

def delete(uri, options = {})
  process_response HTTParty.delete(@base_uri + uri, process_options(options))
end

#get(uri, options = {}) ⇒ Object



14
15
16
# File 'lib/grendel/client.rb', line 14

def get(uri, options = {})
  process_response HTTParty.get(@base_uri + uri, process_options(options))
end

#head(uri, options = {}) ⇒ Object



18
19
20
# File 'lib/grendel/client.rb', line 18

def head(uri, options = {})
  process_response HTTParty.head(@base_uri + uri, process_options(options))
end

#post(uri, data = {}, options = {}) ⇒ Object



22
23
24
# File 'lib/grendel/client.rb', line 22

def post(uri, data = {}, options = {})
  process_response HTTParty.post(@base_uri + uri, process_options(options, data))
end

#put(uri, data = {}, options = {}) ⇒ Object



26
27
28
# File 'lib/grendel/client.rb', line 26

def put(uri, data = {}, options = {})
  process_response HTTParty.put(@base_uri + uri, process_options(options, data))
end

#usersObject



34
35
36
# File 'lib/grendel/client.rb', line 34

def users
  UserManager.new(self)
end