Class: Netscaler::MockAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/netscaler/mock_adapter.rb

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Methods inherited from Adapter

#session, #session=

Constructor Details

#initialize(args = {}) ⇒ MockAdapter

Returns a new instance of MockAdapter.



17
18
19
20
21
22
# File 'lib/netscaler/mock_adapter.rb', line 17

def initialize(args={})
  @result = Result.new

  @response = args[:body] if args.has_key?(:body)

end

Instance Method Details

#delete(part, args = {}) ⇒ Object



80
81
82
83
84
# File 'lib/netscaler/mock_adapter.rb', line 80

def delete(part, args={})
  url = get_uri(part)
  options = prepare_options(args)
  return process_result(@result, @response)
end

#get(part, args = {}) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/netscaler/mock_adapter.rb', line 72

def get(part, args={})
  url = get_uri(part)
  options = prepare_options(args)
  options[:content_type] = :json
  #puts "GET /#{url}"
  return process_result(@result, @response)
end

#post(part, data, args = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/netscaler/mock_adapter.rb', line 24

def post(part, data, args={})
  url = get_uri(part)
  options = prepare_options(args)
  options[:content_type] = :json#'application/json'
  post_data = prepare_payload(data)
  #puts "POST /#{url}\n#{post_data}"

  return process_result(@result, @response)

  #@site[url].post post_data, options do |response, request, result|
  #  return process_result(result, response)
  #end
end

#post_no_body(part, data, args = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/netscaler/mock_adapter.rb', line 38

def post_no_body(part, data, args={})
  url = get_uri(part)
  options = prepare_options(args)
  options[:content_type] = :json #'application/x-www-form-urlencoded'
  post_data = prepare_payload(data)
  #@site[url].post post_data, options
  #puts "POST /#{url}\n#{post_data}"
  return process_result(@result, @response)
end

#put(part, data, args = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/netscaler/mock_adapter.rb', line 48

def put(part, data, args={})
  url = get_uri(part)
  options = prepare_options(args)
  options[:content_type] = :json#'application/json'
  put_data = prepare_payload(data)
  #puts "POST /#{url}\n#{put_data}"

  return process_result(@result, @response)

  #@site[url].post post_data, options do |response, request, result|
  #  return process_result(result, response)
  #end
end

#put_no_body(part, data, args = {}) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/netscaler/mock_adapter.rb', line 62

def put_no_body(part, data, args={})
  url = get_uri(part)
  options = prepare_options(args)
  options[:content_type] = :json #'application/x-www-form-urlencoded'
  put_data = prepare_payload(data)
  #@site[url].put put_data, options
  #puts "POST /#{url}\n#{put_data}"
  return process_result(@result, @response)
end