Class: Codebot::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/codebot/payload.rb

Overview

A JSON request payload.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Payload

Constructs a new payload.

Parameters:

  • payload (String)

    the request payload



14
15
16
# File 'lib/codebot/payload.rb', line 14

def initialize(payload)
  @json = JSON.parse payload
end

Instance Attribute Details

#jsonObject (readonly)

Returns the JSON object parsed from the request payload.

Returns:

  • (Object)

    the JSON object parsed from the request payload



9
10
11
# File 'lib/codebot/payload.rb', line 9

def json
  @json
end

Instance Method Details

#to_jsonObject

Returns the JSON payload.

Returns:

  • (Object)

    the JSON object



21
22
23
# File 'lib/codebot/payload.rb', line 21

def to_json
  @json
end

#to_sString

Returns the JSON string corresponding to the payload.

Returns:

  • (String)

    the JSON string



28
29
30
# File 'lib/codebot/payload.rb', line 28

def to_s
  @json.to_s
end