Class: RedSnow::Payload Abstract

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

Overview

This class is abstract.

HTTP message payload Blueprint AST node

base class for 'payload sections'

Instance Attribute Summary collapse

Attributes inherited from NamedBlueprintNode

#description, #name

Instance Method Summary collapse

Methods inherited from NamedBlueprintNode

#ensure_description_newlines

Constructor Details

#initialize(payload) ⇒ Payload

Returns a new instance of Payload.

Parameters:

  • payload (json)


202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/redsnow/blueprint.rb', line 202

def initialize(payload)
  @name = payload.fetch('name', '')
  @description = payload.fetch('description', '')
  @body = payload.fetch('body', '')
  @schema = payload.fetch('schema', '')

  if payload.key?('reference') && payload['reference'].key?('id')
    @reference = ReferenceNode.new(payload['reference']['id'])
  end

  @headers = Headers.new(payload.fetch('headers', nil))
end

Instance Attribute Details

#bodyString

HTTP-message body or nil

Returns:

  • (String)

    the current value of body



195
196
197
# File 'lib/redsnow/blueprint.rb', line 195

def body
  @body
end

#headersHeaders

array of HTTP header fields of the message or nil

Returns:

  • (Headers)

    the current value of headers



195
196
197
# File 'lib/redsnow/blueprint.rb', line 195

def headers
  @headers
end

#parametersArray

ignored

Returns:

  • (Array)

    the current value of parameters



195
196
197
# File 'lib/redsnow/blueprint.rb', line 195

def parameters
  @parameters
end

#referenceHash

Symbol Reference if the payload is a reference

Returns:

  • (Hash)

    the current value of reference



195
196
197
# File 'lib/redsnow/blueprint.rb', line 195

def reference
  @reference
end

#schemaString

HTTP-message body validation schema or nil

Returns:

  • (String)

    the current value of schema



195
196
197
# File 'lib/redsnow/blueprint.rb', line 195

def schema
  @schema
end