Class: Mountebank::Stub

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

Defined Under Namespace

Classes: HttpResponse, HttpsResponse, Predicate, ProxyResponse, Response, TcpResponse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Stub

Returns a new instance of Stub.



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

def initialize(data={})
  set_attributes(data)
end

Instance Attribute Details

#predicatesObject (readonly)

Returns the value of attribute predicates.



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

def predicates
  @predicates
end

#responsesObject (readonly)

Returns the value of attribute responses.



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

def responses
  @responses
end

Class Method Details

.create(responses = [], predicates = []) ⇒ Object



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

def self.create(responses=[], predicates=[])
  data = {
    :responses => responses,
    :predicates => predicates
  }
  new(data)
end

Instance Method Details

#to_json(*args) ⇒ Object



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

def to_json(*args)
  data = {}
  data[:responses] = @responses unless @responses.empty?
  data[:predicates] = @predicates unless @predicates.empty?
  data.to_json(*args)
end