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.



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

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

Instance Method Details

#bodyObject



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

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

#codeObject



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

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

#headersObject



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

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

#on(host) ⇒ Object



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

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

#pathObject



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

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