Class: RedSnow::TransactionExample

Inherits:
NamedBlueprintNode show all
Defined in:
lib/redsnow/blueprint.rb

Overview

Transaction example Blueprint AST node

Instance Attribute Summary collapse

Attributes inherited from NamedBlueprintNode

#description, #name

Instance Method Summary collapse

Methods inherited from NamedBlueprintNode

#ensure_description_newlines

Constructor Details

#initialize(example) ⇒ TransactionExample

Returns a new instance of TransactionExample.

Parameters:

  • example (json)


225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/redsnow/blueprint.rb', line 225

def initialize(example)
  @name = example.fetch('name', '')
  @description = example.fetch('description', '')

  @requests = []
  example.key?('requests') && example['requests'].each do |request|
    @requests << Payload.new(request).tap do |inst|
      example_instance = self
      inst.define_singleton_method(:example) { example_instance }
    end
  end

  @responses = []
  example.key?('responses') && example['responses'].each do |response|
    @responses << Payload.new(response).tap do |inst|
      example_instance = self
      inst.define_singleton_method(:example) { example_instance }
    end
  end
end

Instance Attribute Details

#requestsArray<Request>

example request payloads

Returns:

  • (Array<Request>)

    the current value of requests



220
221
222
# File 'lib/redsnow/blueprint.rb', line 220

def requests
  @requests
end

#responseArray<Response>

example response payloads

Returns:

  • (Array<Response>)

    the current value of response



220
221
222
# File 'lib/redsnow/blueprint.rb', line 220

def response
  @response
end

#responsesObject

Returns the value of attribute responses.



222
223
224
# File 'lib/redsnow/blueprint.rb', line 222

def responses
  @responses
end