Class: Mountebank::Stub::Predicate
- Inherits:
-
Object
- Object
- Mountebank::Stub::Predicate
- Defined in:
- lib/mountebank/stub/predicate.rb
Constant Summary collapse
- VALID_OPERATORS =
[ :equals, :deepEquals, :contains, :startsWith, :endsWith, :matches, :exists, :not, :or, :and, :inject ]
Instance Attribute Summary collapse
-
#and ⇒ Object
Returns the value of attribute and.
-
#caseSensitive ⇒ Object
Returns the value of attribute caseSensitive.
-
#contains ⇒ Object
Returns the value of attribute contains.
-
#deepEquals ⇒ Object
Returns the value of attribute deepEquals.
-
#endsWith ⇒ Object
Returns the value of attribute endsWith.
-
#equals ⇒ Object
Returns the value of attribute equals.
-
#except ⇒ Object
Returns the value of attribute except.
-
#exists ⇒ Object
Returns the value of attribute exists.
-
#inject ⇒ Object
Returns the value of attribute inject.
-
#matches ⇒ Object
Returns the value of attribute matches.
-
#not ⇒ Object
Returns the value of attribute not.
-
#or ⇒ Object
Returns the value of attribute or.
-
#startsWith ⇒ Object
Returns the value of attribute startsWith.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ Predicate
constructor
A new instance of Predicate.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Predicate
Returns a new instance of Predicate.
9 10 11 12 13 14 15 |
# File 'lib/mountebank/stub/predicate.rb', line 9 def initialize(data={}) VALID_OPERATORS.each do |key| send("#{key}=", data[key]) if data.key?(key) end @caseSensitive = data[:caseSensitive] || nil @except = data[:except] || nil end |
Instance Attribute Details
#and ⇒ Object
Returns the value of attribute and.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def and @and end |
#caseSensitive ⇒ Object
Returns the value of attribute caseSensitive.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def caseSensitive @caseSensitive end |
#contains ⇒ Object
Returns the value of attribute contains.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def contains @contains end |
#deepEquals ⇒ Object
Returns the value of attribute deepEquals.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def deepEquals @deepEquals end |
#endsWith ⇒ Object
Returns the value of attribute endsWith.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def endsWith @endsWith end |
#equals ⇒ Object
Returns the value of attribute equals.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def equals @equals end |
#except ⇒ Object
Returns the value of attribute except.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def except @except end |
#exists ⇒ Object
Returns the value of attribute exists.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def exists @exists end |
#inject ⇒ Object
Returns the value of attribute inject.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def inject @inject end |
#matches ⇒ Object
Returns the value of attribute matches.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def matches @matches end |
#not ⇒ Object
Returns the value of attribute not.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def not @not end |
#or ⇒ Object
Returns the value of attribute or.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def or @or end |
#startsWith ⇒ Object
Returns the value of attribute startsWith.
2 3 4 |
# File 'lib/mountebank/stub/predicate.rb', line 2 def startsWith @startsWith end |
Instance Method Details
#to_json(*args) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mountebank/stub/predicate.rb', line 17 def to_json(*args) data = {} VALID_OPERATORS.each do |key| data[key] = send("#{key}") if instance_variable_defined?("@#{key}") end data[:caseSensitive] = @caseSensitive unless @caseSensitive.nil? data[:except] = @except unless @except.nil? data.to_json(*args) end |