Class: Mountebank::Stub
- Inherits:
-
Object
- Object
- Mountebank::Stub
- Defined in:
- lib/mountebank/stub.rb
Defined Under Namespace
Classes: HttpResponse, HttpsResponse, Predicate, ProxyResponse, Response, TcpResponse
Instance Attribute Summary collapse
-
#predicates ⇒ Object
readonly
Returns the value of attribute predicates.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ Stub
constructor
A new instance of Stub.
- #to_json(*args) ⇒ Object
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
#predicates ⇒ Object (readonly)
Returns the value of attribute predicates.
2 3 4 |
# File 'lib/mountebank/stub.rb', line 2 def predicates @predicates end |
#responses ⇒ Object (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 |