Class: Mountebank::Stub::Predicate

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#andObject

Returns the value of attribute and.



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

def and
  @and
end

#caseSensitiveObject

Returns the value of attribute caseSensitive.



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

def caseSensitive
  @caseSensitive
end

#containsObject

Returns the value of attribute contains.



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

def contains
  @contains
end

#deepEqualsObject

Returns the value of attribute deepEquals.



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

def deepEquals
  @deepEquals
end

#endsWithObject

Returns the value of attribute endsWith.



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

def endsWith
  @endsWith
end

#equalsObject

Returns the value of attribute equals.



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

def equals
  @equals
end

#exceptObject

Returns the value of attribute except.



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

def except
  @except
end

#existsObject

Returns the value of attribute exists.



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

def exists
  @exists
end

#injectObject

Returns the value of attribute inject.



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

def inject
  @inject
end

#matchesObject

Returns the value of attribute matches.



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

def matches
  @matches
end

#notObject

Returns the value of attribute not.



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

def not
  @not
end

#orObject

Returns the value of attribute or.



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

def or
  @or
end

#startsWithObject

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