Class: MockServer::CaptureRule

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Overview

A single expectation-level capture rule (org.mockserver.model.CaptureRule): extract a value from the matched request via +source+/+expression+ and store it under the into key for use by later actions/templates.

source is the wire enum value, one of: "jsonPath", "xpath", "header", "queryStringParameter", "cookie", "pathParameter".

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source: nil, expression: nil, into: nil) ⇒ CaptureRule

Returns a new instance of CaptureRule.



2246
2247
2248
2249
2250
# File 'lib/mockserver/models.rb', line 2246

def initialize(source: nil, expression: nil, into: nil)
  @source = source
  @expression = expression
  @into = into
end

Instance Attribute Details

#expressionObject

Returns the value of attribute expression.



2244
2245
2246
# File 'lib/mockserver/models.rb', line 2244

def expression
  @expression
end

#intoObject

Returns the value of attribute into.



2244
2245
2246
# File 'lib/mockserver/models.rb', line 2244

def into
  @into
end

#sourceObject

Returns the value of attribute source.



2244
2245
2246
# File 'lib/mockserver/models.rb', line 2244

def source
  @source
end

Class Method Details

.from_hash(data) ⇒ Object



2260
2261
2262
2263
2264
2265
2266
2267
2268
# File 'lib/mockserver/models.rb', line 2260

def self.from_hash(data)
  return nil if data.nil?

  new(
    source:     data['source'],
    expression: data['expression'],
    into:       data['into']
  )
end

Instance Method Details

#to_hObject



2252
2253
2254
2255
2256
2257
2258
# File 'lib/mockserver/models.rb', line 2252

def to_h
  MockServer.strip_none({
    'source'     => @source,
    'expression' => @expression,
    'into'       => @into
  })
end