Class: Restulicious::Adapter::RESTApi

Inherits:
Object
  • Object
show all
Defined in:
lib/restulicious/adapter/rest_api.rb

Instance Method Summary collapse

Constructor Details

#initialize(klazz, key, request_options, headers) ⇒ RESTApi

Returns a new instance of RESTApi.



6
7
8
9
# File 'lib/restulicious/adapter/rest_api.rb', line 6

def initialize(klazz, key, request_options, headers)
  @klazz = klazz
  @key   = key
end

Instance Method Details

#get(url, params, &block) ⇒ Object



11
12
13
14
# File 'lib/restulicious/adapter/rest_api.rb', line 11

def get(url, params, &block)
  @request = ::RESTApi.get(url, params)
  handle_response(&block)
end

#on_complete(&block) ⇒ Object



30
31
32
# File 'lib/restulicious/adapter/rest_api.rb', line 30

def on_complete(&block)
  @on_complete = block
end

#on_failure(&block) ⇒ Object



34
35
36
# File 'lib/restulicious/adapter/rest_api.rb', line 34

def on_failure(&block)
  @on_failure = block
end

#on_success(&block) ⇒ Object



26
27
28
# File 'lib/restulicious/adapter/rest_api.rb', line 26

def on_success(&block)
  @on_success = block
end

#post(url, params, &block) ⇒ Object



16
17
18
19
# File 'lib/restulicious/adapter/rest_api.rb', line 16

def post(url, params, &block)
  @request = ::RESTApi.post(url, params)
  handle_response(&block)
end

#put(url, params, &block) ⇒ Object



21
22
23
24
# File 'lib/restulicious/adapter/rest_api.rb', line 21

def put(url, params, &block)
  @request = ::RESTApi.put(url, params)
  handle_response(&block)
end