Class: Mountebank::Stub::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/mountebank/stub/response.rb

Direct Known Subclasses

HttpResponse, ProxyResponse, TcpResponse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Response

Returns a new instance of Response.



4
5
6
7
8
# File 'lib/mountebank/stub/response.rb', line 4

def initialize(data={})
  @is = data[:is] || nil
  @proxy = data[:proxy] || nil
  @inject = data[:inject] || nil
end

Instance Attribute Details

#injectObject

Returns the value of attribute inject.



2
3
4
# File 'lib/mountebank/stub/response.rb', line 2

def inject
  @inject
end

#isObject

Returns the value of attribute is.



2
3
4
# File 'lib/mountebank/stub/response.rb', line 2

def is
  @is
end

#proxyObject

Returns the value of attribute proxy.



2
3
4
# File 'lib/mountebank/stub/response.rb', line 2

def proxy
  @proxy
end

Class Method Details

.with_injection(injection = '') ⇒ Object



10
11
12
13
14
15
# File 'lib/mountebank/stub/response.rb', line 10

def self.with_injection(injection='')
  return false if injection.empty?

  data = {inject:injection}
  new(data)
end

Instance Method Details

#to_json(*args) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/mountebank/stub/response.rb', line 17

def to_json(*args)
  data = {}
  data[:is] = @is unless @is.nil?
  data[:proxy] = @proxy unless @proxy.nil?
  data[:inject] = @inject unless @inject.nil?
  data.to_json(*args)
end