Class: Mimic::API::APIRequest::Stub

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

Instance Method Summary collapse

Constructor Details

#initialize(data, method = nil) ⇒ Stub

Returns a new instance of Stub.



64
65
66
67
# File 'lib/mimic/api.rb', line 64

def initialize(data, method = nil)
  @data = data
  @method = method
end

Instance Method Details

#bodyObject



77
78
79
# File 'lib/mimic/api.rb', line 77

def body
  @data['body'] || ''
end

#codeObject



81
82
83
# File 'lib/mimic/api.rb', line 81

def code
  @data['code'] || 200
end

#headersObject



85
86
87
# File 'lib/mimic/api.rb', line 85

def headers
  @data['headers'] || {}
end

#on(host) ⇒ Object



69
70
71
# File 'lib/mimic/api.rb', line 69

def on(host)
  host.send(@method.downcase.to_sym, path).returning(body, code, headers)
end

#pathObject



73
74
75
# File 'lib/mimic/api.rb', line 73

def path
  @data['path'] || '/'
end